mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-10 06:40:16 +00:00
mbedtls_asn1_get_bitstring_null: fix rejection of short inputs
Fix improper rejection of bitstrings with length less than 2.
This commit is contained in:
parent
f7d6acd475
commit
e40d1207eb
@ -230,8 +230,13 @@ int mbedtls_asn1_get_bitstring_null( unsigned char **p, const unsigned char *end
|
|||||||
if( ( ret = mbedtls_asn1_get_tag( p, end, len, MBEDTLS_ASN1_BIT_STRING ) ) != 0 )
|
if( ( ret = mbedtls_asn1_get_tag( p, end, len, MBEDTLS_ASN1_BIT_STRING ) ) != 0 )
|
||||||
return( ret );
|
return( ret );
|
||||||
|
|
||||||
if( (*len)-- < 2 || *(*p)++ != 0 )
|
if( *len == 0 )
|
||||||
return( MBEDTLS_ERR_ASN1_INVALID_DATA );
|
return( MBEDTLS_ERR_ASN1_INVALID_DATA );
|
||||||
|
--( *len );
|
||||||
|
|
||||||
|
if( **p != 0 )
|
||||||
|
return( MBEDTLS_ERR_ASN1_INVALID_DATA );
|
||||||
|
++( *p );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user