Fix checks for nul-termination

This commit is contained in:
Manuel Pégourié-Gonnard 2015-05-12 12:43:54 +02:00
parent 24083d61a0
commit 0ece0f94f2
5 changed files with 9 additions and 9 deletions

View file

@ -422,7 +422,7 @@ int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin,
mbedtls_pem_init( &pem );
/* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */
if( dhmin[dhminlen - 1] != '\0' )
if( dhminlen == 0 || dhmin[dhminlen - 1] != '\0' )
ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT;
else
ret = mbedtls_pem_read_buffer( &pem,