mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-23 15:55:10 +01:00
Address user reported coverity issues.
This commit is contained in:
parent
78da223f68
commit
ce52d7823c
17 changed files with 81 additions and 41 deletions
|
|
@ -970,7 +970,9 @@ int mbedtls_x509_crt_parse_der( mbedtls_x509_crt *chain, const unsigned char *bu
|
|||
int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen )
|
||||
{
|
||||
int success = 0, first_error = 0, total_failed = 0;
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
int buf_format = MBEDTLS_X509_FORMAT_DER;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check for valid input
|
||||
|
|
@ -988,10 +990,12 @@ int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, s
|
|||
{
|
||||
buf_format = MBEDTLS_X509_FORMAT_PEM;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( buf_format == MBEDTLS_X509_FORMAT_DER )
|
||||
return mbedtls_x509_crt_parse_der( chain, buf, buflen );
|
||||
#else
|
||||
return mbedtls_x509_crt_parse_der( chain, buf, buflen );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
if( buf_format == MBEDTLS_X509_FORMAT_PEM )
|
||||
|
|
@ -1064,7 +1068,6 @@ int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, s
|
|||
success = 1;
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_PEM_PARSE_C */
|
||||
|
||||
if( success )
|
||||
return( total_failed );
|
||||
|
|
@ -1072,6 +1075,7 @@ int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, s
|
|||
return( first_error );
|
||||
else
|
||||
return( MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT );
|
||||
#endif /* MBEDTLS_PEM_PARSE_C */
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
|
|
@ -1353,6 +1357,14 @@ int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix,
|
|||
p = buf;
|
||||
n = size;
|
||||
|
||||
if( NULL == crt )
|
||||
{
|
||||
ret = mbedtls_snprintf( p, n, "\nCertificate is uninitialised!\n" );
|
||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||
|
||||
return( (int) ( size - n ) );
|
||||
}
|
||||
|
||||
ret = mbedtls_snprintf( p, n, "%scert. version : %d\n",
|
||||
prefix, crt->version );
|
||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue