Merge branch 'mbedtls-1.3' into mbedtls-1.3-restricted

* mbedtls-1.3:
  Remove %zu format string from ssl_client2 and ssl_server2
This commit is contained in:
Manuel Pégourié-Gonnard 2017-06-09 17:41:46 +02:00
commit 7880cb40f4
2 changed files with 22 additions and 18 deletions

View File

@ -264,6 +264,10 @@ int main( void )
return( 0 ); return( 0 );
} }
#else #else
#define ALPN_LIST_SIZE 10
#define CURVE_LIST_SIZE 20
/* /*
* global options * global options
*/ */
@ -385,10 +389,10 @@ int main( int argc, char *argv[] )
size_t psk_len = 0; size_t psk_len = 0;
#endif #endif
#if defined(POLARSSL_SSL_ALPN) #if defined(POLARSSL_SSL_ALPN)
const char *alpn_list[10]; const char *alpn_list[ALPN_LIST_SIZE];
#endif #endif
#if defined(POLARSSL_SSL_SET_CURVES) #if defined(POLARSSL_SSL_SET_CURVES)
ecp_group_id curve_list[20]; ecp_group_id curve_list[CURVE_LIST_SIZE];
const ecp_curve_info *curve_cur; const ecp_curve_info *curve_cur;
#endif #endif
@ -810,8 +814,7 @@ int main( int argc, char *argv[] )
else if( strcmp( p, "default" ) != 0 ) else if( strcmp( p, "default" ) != 0 )
{ {
/* Leave room for a final NULL in curve list */ /* Leave room for a final NULL in curve list */
while( i < (int) ( sizeof( curve_list ) / sizeof( *curve_list ) ) - 1 while( i < CURVE_LIST_SIZE - 1 && *p != '\0' )
&& *p != '\0' )
{ {
q = p; q = p;
@ -842,11 +845,10 @@ int main( int argc, char *argv[] )
polarssl_printf( "Number of curves: %d\n", i ); polarssl_printf( "Number of curves: %d\n", i );
if( i == (int) ( sizeof( curve_list ) / sizeof( *curve_list ) ) - 1 if( i == CURVE_LIST_SIZE - 1 && *p != '\0' )
&& *p != '\0' )
{ {
polarssl_printf( "curves list too long, maximum %zu", polarssl_printf( "curves list too long, maximum %d",
(size_t) ( sizeof( curve_list ) / sizeof( *curve_list ) - 1 ) ); CURVE_LIST_SIZE - 1 );
goto exit; goto exit;
} }
@ -862,7 +864,7 @@ int main( int argc, char *argv[] )
i = 0; i = 0;
/* Leave room for a final NULL in alpn_list */ /* Leave room for a final NULL in alpn_list */
while( i < (int) sizeof alpn_list - 1 && *p != '\0' ) while( i < ALPN_LIST_SIZE - 1 && *p != '\0' )
{ {
alpn_list[i++] = p; alpn_list[i++] = p;

View File

@ -303,6 +303,10 @@ int main( void )
return( 0 ); return( 0 );
} }
#else #else
#define ALPN_LIST_SIZE 10
#define CURVE_LIST_SIZE 20
/* /*
* global options * global options
*/ */
@ -697,10 +701,10 @@ int main( int argc, char *argv[] )
sni_entry *sni_info = NULL; sni_entry *sni_info = NULL;
#endif #endif
#if defined(POLARSSL_SSL_ALPN) #if defined(POLARSSL_SSL_ALPN)
const char *alpn_list[10]; const char *alpn_list[ALPN_LIST_SIZE];
#endif #endif
#if defined(POLARSSL_SSL_SET_CURVES) #if defined(POLARSSL_SSL_SET_CURVES)
ecp_group_id curve_list[20]; ecp_group_id curve_list[CURVE_LIST_SIZE];
const ecp_curve_info *curve_cur; const ecp_curve_info *curve_cur;
#endif #endif
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
@ -1152,8 +1156,7 @@ int main( int argc, char *argv[] )
else if( strcmp( p, "default" ) != 0 ) else if( strcmp( p, "default" ) != 0 )
{ {
/* Leave room for a final NULL in curve list */ /* Leave room for a final NULL in curve list */
while( i < (int) ( sizeof( curve_list ) / sizeof( *curve_list ) ) - 1 while( i < CURVE_LIST_SIZE - 1 && *p != '\0' )
&& *p != '\0' )
{ {
q = p; q = p;
@ -1184,11 +1187,10 @@ int main( int argc, char *argv[] )
polarssl_printf( "Number of curves: %d\n", i ); polarssl_printf( "Number of curves: %d\n", i );
if( i == (int) ( sizeof( curve_list ) / sizeof( *curve_list ) ) - 1 if( i == CURVE_LIST_SIZE - 1 && *p != '\0' )
&& *p != '\0' )
{ {
polarssl_printf( "curves list too long, maximum %zu", polarssl_printf( "curves list too long, maximum %d",
(size_t) ( sizeof( curve_list ) / sizeof( *curve_list ) - 1 ) ); CURVE_LIST_SIZE - 1 );
goto exit; goto exit;
} }
@ -1204,7 +1206,7 @@ int main( int argc, char *argv[] )
i = 0; i = 0;
/* Leave room for a final NULL in alpn_list */ /* Leave room for a final NULL in alpn_list */
while( i < (int) sizeof alpn_list - 1 && *p != '\0' ) while( i < ALPN_LIST_SIZE - 1 && *p != '\0' )
{ {
alpn_list[i++] = p; alpn_list[i++] = p;