mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 01:35:38 +00:00
Fix argument validation in asn1_write_10x
1 << bits doesn't work when bits is too large. Found by ASan.
This commit is contained in:
parent
0c938be967
commit
480416af9d
|
@ -46,7 +46,9 @@ static int asn1_write_10x( unsigned char **p,
|
|||
{
|
||||
int ret;
|
||||
int len = bits / 8 + 1;
|
||||
if( x >= 1 << bits )
|
||||
if( bits == 0 )
|
||||
return( MBEDTLS_ERR_ASN1_INVALID_DATA );
|
||||
if( bits <= 8 && x >= 1 << ( bits - 1 ) )
|
||||
return( MBEDTLS_ERR_ASN1_INVALID_DATA );
|
||||
if( *p < start || *p - start < (ssize_t) len )
|
||||
return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
|
||||
|
|
Loading…
Reference in a new issue