mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-04-25 21:18:53 +02:00
Merge pull request #3192 from AndrzejKurek/max_pathlen_overflow
Guard from undefined behaviour in case of an INT_MAX max_pathlen
This commit is contained in:
@@ -524,6 +524,12 @@ static int x509_get_basic_constraints( unsigned char **p,
|
||||
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
|
||||
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
|
||||
|
||||
/* Do not accept max_pathlen equal to INT_MAX to avoid a signed integer
|
||||
* overflow, which is an undefined behavior. */
|
||||
if( *max_pathlen == INT_MAX )
|
||||
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
|
||||
MBEDTLS_ERR_ASN1_INVALID_LENGTH );
|
||||
|
||||
(*max_pathlen)++;
|
||||
|
||||
return( 0 );
|
||||
|
||||
Reference in New Issue
Block a user