mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2026-04-07 15:36:29 +00: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:
commit
31f4cd9de2
4 changed files with 54 additions and 0 deletions
|
|
@ -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 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue