Merge pull request #5298 from paul-elliott-arm/ssl_context_info_prog_2.x

Backport 2.x: Two fixes for SSL context info sample program
This commit is contained in:
Gilles Peskine 2021-12-09 23:22:54 +01:00 committed by GitHub
commit c2c1c22dda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,6 +22,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/debug.h"
#include <stdio.h>
#include <stdlib.h>
@ -164,6 +165,7 @@ void printf_dbg( const char *str, ... )
}
}
MBEDTLS_PRINTF_ATTRIBUTE( 1, 2 )
void printf_err( const char *str, ... )
{
va_list args;
@ -222,7 +224,13 @@ void parse_arguments( int argc, char *argv[] )
error_exit();
}
if( ( b64_file = fopen( argv[i], "r" ) ) == NULL )
if( NULL != b64_file )
{
printf_err( "Cannot specify more than one file with -f\n" );
error_exit( );
}
if( ( b64_file = fopen( argv[i], "r" )) == NULL )
{
printf_err( "Cannot find file \"%s\"\n", argv[i] );
error_exit();
@ -464,7 +472,8 @@ size_t read_next_b64_code( uint8_t **b64, size_t *max_len )
}
else if( len > *max_len )
{
printf_err( "The code found is too large by %u bytes.\n", len - *max_len );
printf_err( "The code found is too large by %" MBEDTLS_PRINTF_SIZET " bytes.\n",
len - *max_len );
len = pad = 0;
}
else if( len % 4 != 0 )