]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Check the return value of ASN1_STRING_length
authorbonniegong <yuanjungong96@gmail.com>
Wed, 2 Jun 2021 07:35:18 +0000 (15:35 +0800)
committerTomas Mraz <tomas@openssl.org>
Thu, 3 Jun 2021 15:09:02 +0000 (17:09 +0200)
ASN1_STRING_length gets the field 'length' of msg, which
can be manipulated through a crafted input.
Add a check to avoid error execution of OPENSSL_malloc().

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15583)

crypto/ts/ts_verify_ctx.c

index 825d53e4f70f7b51949e7eeeb4b0d70356a020f1..20268339ee5d9a218d8d6ef40514673ec1efd9e5 100644 (file)
@@ -126,6 +126,8 @@ TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx)
         goto err;
     msg = imprint->hashed_msg;
     ret->imprint_len = ASN1_STRING_length(msg);
+    if (ret->imprint_len <= 0)
+        goto err;
     if ((ret->imprint = OPENSSL_malloc(ret->imprint_len)) == NULL)
         goto err;
     memcpy(ret->imprint, ASN1_STRING_get0_data(msg), ret->imprint_len);