mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-24 00:01:21 +00:00
Fix x509_get_subject_alt_name to drop invalid tag
Fix the x509_get_subject_alt_name() function to not accept invalid tags. The problem was that the ASN.1 class for tags consists of two bits. Simply doing bit-wise and of the CONTEXT_SPECIFIC macro with the input tag has the potential of accepting tag values 0x10 (private) which would indicate that the certificate has an incorrect format.
This commit is contained in:
parent
45a556501c
commit
f6a6b82362
|
@ -472,9 +472,12 @@ static int x509_get_subject_alt_name( unsigned char **p,
|
||||||
if( ( ret = mbedtls_asn1_get_len( p, end, &tag_len ) ) != 0 )
|
if( ( ret = mbedtls_asn1_get_len( p, end, &tag_len ) ) != 0 )
|
||||||
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
|
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
|
||||||
|
|
||||||
if( ( tag & MBEDTLS_ASN1_CONTEXT_SPECIFIC ) != MBEDTLS_ASN1_CONTEXT_SPECIFIC )
|
if( ( tag & MBEDTLS_ASN1_TAG_CLASS_MASK ) !=
|
||||||
|
MBEDTLS_ASN1_CONTEXT_SPECIFIC )
|
||||||
|
{
|
||||||
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
|
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
|
||||||
MBEDTLS_ERR_ASN1_UNEXPECTED_TAG );
|
MBEDTLS_ERR_ASN1_UNEXPECTED_TAG );
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip everything but DNS name */
|
/* Skip everything but DNS name */
|
||||||
if( tag != ( MBEDTLS_ASN1_CONTEXT_SPECIFIC | 2 ) )
|
if( tag != ( MBEDTLS_ASN1_CONTEXT_SPECIFIC | 2 ) )
|
||||||
|
|
Loading…
Reference in a new issue