Add handlers for parameter validation in the sample programs

The sample programs require an additional handler function of
mbedtls_param_failed() to handle any failed parameter validation checks enabled
by the MBEDTLS_CHECK_PARAMS config.h option.
This commit is contained in:
Simon Butcher 2018-12-06 17:43:31 +00:00 committed by Manuel Pégourié-Gonnard
parent a646345e3f
commit 63cb97e562
37 changed files with 312 additions and 0 deletions

View file

@ -79,6 +79,14 @@ int main( void )
#define DEBUG_LEVEL 0
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
static void my_debug( void *ctx, int level,
const char *file, int line,
const char *str )

View file

@ -88,6 +88,14 @@ int main( void )
#define READ_TIMEOUT_MS 10000 /* 5 seconds */
#define DEBUG_LEVEL 0
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
static void my_debug( void *ctx, int level,
const char *file, int line,
const char *str )

View file

@ -168,6 +168,14 @@ enum exit_codes
ssl_write_failed,
};
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
int main( void )
{
int ret = exit_ok;

View file

@ -70,6 +70,14 @@ int main( void )
#define DEBUG_LEVEL 1
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
static void my_debug( void *ctx, int level,
const char *file, int line,
const char *str )

View file

@ -314,6 +314,14 @@ int main( void )
#define ALPN_LIST_SIZE 10
#define CURVE_LIST_SIZE 20
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
/*
* global options
*/

View file

@ -86,6 +86,14 @@ int main( void )
#define DEBUG_LEVEL 0
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
static void my_debug( void *ctx, int level,
const char *file, int line,
const char *str )

View file

@ -141,6 +141,14 @@ int main( void )
" force_ciphersuite=<name> default: all enabled\n"\
" acceptable ciphersuite names:\n"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
/*
* global options
*/

View file

@ -80,6 +80,14 @@ int main( void )
#define DEBUG_LEVEL 0
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
static void my_debug( void *ctx, int level,
const char *file, int line,
const char *str )

View file

@ -426,6 +426,14 @@ int main( void )
(out_be)[(i) + 7] = (unsigned char)( ( (in_le) >> 0 ) & 0xFF ); \
}
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C)
void mbedtls_param_failed( char* failure_condition, char* file, int line )
{
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
/*
* global options
*/