Handle existence of OpenSSL Trust Extensions at end of X.509 DER blob

(cherry picked from commit b00ca42f2a)

Conflicts:
	ChangeLog (Moved message to 'Branch 1.1')
This commit is contained in:
Paul Bakker 2013-01-14 16:40:55 +01:00
parent a4ed0c9a76
commit 47f626184c
2 changed files with 6 additions and 4 deletions

View file

@ -3,6 +3,7 @@ PolarSSL ChangeLog
= Branch 1.1 = Branch 1.1
Bugfix Bugfix
* Fixed MPI assembly for SPARC64 platform * Fixed MPI assembly for SPARC64 platform
* Handle existence of OpenSSL Trust Extensions at end of X.509 DER blob
Security Security
* Fixed potential memory zeroization on miscrafted RSA key (found by Eloi * Fixed potential memory zeroization on miscrafted RSA key (found by Eloi

View file

@ -1018,7 +1018,7 @@ int x509parse_crt_der( x509_cert *crt, const unsigned char *buf, size_t buflen )
{ {
int ret; int ret;
size_t len; size_t len;
unsigned char *p, *end; unsigned char *p, *end, *crt_end;
/* /*
* Check for valid input * Check for valid input
@ -1052,12 +1052,13 @@ int x509parse_crt_der( x509_cert *crt, const unsigned char *buf, size_t buflen )
return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT );
} }
if( len != (size_t) ( end - p ) ) if( len > (size_t) ( end - p ) )
{ {
x509_free( crt ); x509_free( crt );
return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT +
POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); POLARSSL_ERR_ASN1_LENGTH_MISMATCH );
} }
crt_end = p + len;
/* /*
* TBSCertificate ::= SEQUENCE { * TBSCertificate ::= SEQUENCE {
@ -1228,7 +1229,7 @@ int x509parse_crt_der( x509_cert *crt, const unsigned char *buf, size_t buflen )
POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); POLARSSL_ERR_ASN1_LENGTH_MISMATCH );
} }
end = crt->raw.p + crt->raw.len; end = crt_end;
/* /*
* signatureAlgorithm AlgorithmIdentifier, * signatureAlgorithm AlgorithmIdentifier,