pkcs7: check that content lengths fill whole buffer

Otherwise invalid data could be accepted.

Signed-off-by: Demi Marie Obenour <[email protected]>
Signed-off-by: Dave Rodgman <[email protected]>
This commit is contained in:
Demi Marie Obenour
2023-02-10 12:56:10 +00:00
committed by Dave Rodgman
parent a22749e749
commit 512818b1d2
+3
View File
@@ -58,6 +58,9 @@ static int pkcs7_get_next_content_len(unsigned char **p, unsigned char *end,
| MBEDTLS_ASN1_CONTEXT_SPECIFIC);
if (ret != 0) {
ret = MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS7_INVALID_FORMAT, ret);
} else if ((size_t) (end - *p) != *len) {
ret = MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS7_INVALID_FORMAT,
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
}
return ret;