diff options
author | Hanno Becker <hanno.becker@arm.com> | 2019-09-13 14:21:13 +0100 |
---|---|---|
committer | David Horstmann <david.horstmann@arm.com> | 2023-01-10 15:13:03 +0000 |
commit | e7ff797e7e214c5ddeed1e22250aea3a32bb47d9 (patch) | |
tree | 7e46d185e18f8dfc6a1fbae825d7fb9bf00e165c | |
parent | 65b20a3649325eeafaaf062071ec9ff2660d1fd5 (diff) | |
download | mbedtls-e7ff797e7e214c5ddeed1e22250aea3a32bb47d9.zip mbedtls-e7ff797e7e214c5ddeed1e22250aea3a32bb47d9.tar.gz mbedtls-e7ff797e7e214c5ddeed1e22250aea3a32bb47d9.tar.bz2 |
X.509: Add length consistency checks to x509_get_other_name()
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
-rw-r--r-- | library/x509_crt.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/library/x509_crt.c b/library/x509_crt.c index c4bb3ae..bc7818a 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -1756,11 +1756,21 @@ static int x509_get_other_name(const mbedtls_x509_buf *subject_alt_name, return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret); } + if (end != p + len) { + return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH); + } + if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) { return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret); } + if (end != p + len) { + return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH); + } + if ((ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_OID)) != 0) { return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret); } |