Skip to content

Commit 74c4330

Browse files
mbedtls_asn1_get_bitstring_null: fix rejection of short inputs
Fix improper rejection of bitstrings with length less than 2.
1 parent 4818922 commit 74c4330

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/asn1parse.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,13 @@ int mbedtls_asn1_get_bitstring_null( unsigned char **p, const unsigned char *end
230230
if( ( ret = mbedtls_asn1_get_tag( p, end, len, MBEDTLS_ASN1_BIT_STRING ) ) != 0 )
231231
return( ret );
232232

233-
if( (*len)-- < 2 || *(*p)++ != 0 )
233+
if( *len == 0 )
234234
return( MBEDTLS_ERR_ASN1_INVALID_DATA );
235+
--( *len );
236+
237+
if( **p != 0 )
238+
return( MBEDTLS_ERR_ASN1_INVALID_DATA );
239+
++( *p );
235240

236241
return( 0 );
237242
}

0 commit comments

Comments
 (0)