mirror of
				https://github.com/yuzu-emu/mbedtls.git
				synced 2025-11-04 09:15:05 +00:00 
			
		
		
		
	Move bounds check into ASN.1 parsing function
`x509_get_attr_type_value()` checks for the presence of a tag byte and reads and stores it before calling `mbedtls_asn1_get_tag()` which fails if either the tag byte is not present or not as expected. Therefore, the manual check can be removed and left to `mbedtls_asn1_get_tag()`, and the tag can be hardcoded after the call succeeded. This saves a few bytes of code.
This commit is contained in:
		
							parent
							
								
									74b89f6051
								
							
						
					
					
						commit
						ace04a6dc3
					
				| 
						 | 
				
			
			@ -362,17 +362,12 @@ static int x509_get_attr_type_value( unsigned char **p,
 | 
			
		|||
        return( MBEDTLS_ERR_X509_INVALID_NAME + ret );
 | 
			
		||||
 | 
			
		||||
    end = *p + len;
 | 
			
		||||
 | 
			
		||||
    if( ( end - *p ) < 1 )
 | 
			
		||||
        return( MBEDTLS_ERR_X509_INVALID_NAME +
 | 
			
		||||
                MBEDTLS_ERR_ASN1_OUT_OF_DATA );
 | 
			
		||||
 | 
			
		||||
    oid = &cur->oid;
 | 
			
		||||
    oid->tag = **p;
 | 
			
		||||
 | 
			
		||||
    if( ( ret = mbedtls_asn1_get_tag( p, end, &oid->len, MBEDTLS_ASN1_OID ) ) != 0 )
 | 
			
		||||
        return( MBEDTLS_ERR_X509_INVALID_NAME + ret );
 | 
			
		||||
 | 
			
		||||
    oid->tag = MBEDTLS_ASN1_OID;
 | 
			
		||||
    oid->p = *p;
 | 
			
		||||
    *p += oid->len;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue