mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 12:05:36 +01:00
Fix the build of sample programs without mbedtls_strerror
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
0f4e3fbd10
commit
3f0722c1af
3
ChangeLog.d/no-strerror.txt
Normal file
3
ChangeLog.d/no-strerror.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Bugfix
|
||||
* Fix the build of sample programs when neither MBEDTLS_ERROR_C nor
|
||||
MBEDTLS_ERROR_STRERROR_DUMMY is enabled.
|
@ -197,7 +197,9 @@ int main( int argc, char *argv[] )
|
||||
{
|
||||
int ret = 1;
|
||||
int exit_code = MBEDTLS_EXIT_FAILURE;
|
||||
char buf[1024];
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
char buf[200];
|
||||
#endif
|
||||
int i;
|
||||
char *p, *q;
|
||||
|
||||
@ -208,7 +210,9 @@ int main( int argc, char *argv[] )
|
||||
* Set to sane values
|
||||
*/
|
||||
mbedtls_pk_init( &key );
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
#endif
|
||||
|
||||
mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
|
||||
mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
|
||||
@ -296,8 +300,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_strerror( ret, (char *) buf, sizeof(buf) );
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x", (unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -357,8 +360,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_strerror( ret, (char *) buf, sizeof(buf) );
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_key returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_key returned -0x%04x", (unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,6 @@ int read_certificates( const char *const *filenames )
|
||||
mbedtls_x509_crt cas;
|
||||
int ret = 0;
|
||||
const char *const *cur;
|
||||
char error_message[200];
|
||||
|
||||
mbedtls_x509_crt_init( &cas );
|
||||
|
||||
@ -118,9 +117,15 @@ int read_certificates( const char *const *filenames )
|
||||
ret = mbedtls_x509_crt_parse_file( &cas, *cur );
|
||||
if( ret != 0 )
|
||||
{
|
||||
#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
|
||||
char error_message[200];
|
||||
mbedtls_strerror( ret, error_message, sizeof( error_message ) );
|
||||
printf( "\n%s: -0x%04x (%s)\n",
|
||||
*cur, (unsigned) -ret, error_message );
|
||||
#else
|
||||
printf( "\n%s: -0x%04x\n",
|
||||
*cur, (unsigned) -ret );
|
||||
#endif
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user