]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
asn1: clear error mark on success in asn1_d2i_read_bio
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 11 Oct 2025 12:40:13 +0000 (20:40 +0800)
committerTomas Mraz <tomas@openssl.org>
Mon, 24 Nov 2025 18:12:16 +0000 (19:12 +0100)
Balance ERR_set_mark by calling ERR_clear_last_mark on the success path.
Prevents a stale mark from skewing later error handling.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28882)

(cherry picked from commit 7f015c909ee3480a59d4fe828c3da22c7a55a2f4)

crypto/asn1/a_d2i_fp.c

index 4999ac1f65ba953225910595ca302bbe5eb611e7..d5b7cd2a2a0b2882b8d67cd33580e22e3853de85 100644 (file)
@@ -168,6 +168,7 @@ int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
             if (e != ASN1_R_TOO_LONG)
                 goto err;
             ERR_pop_to_mark();
+            ERR_set_mark();
         }
         i = q - p;            /* header length */
         off += i;               /* end of data */
@@ -248,6 +249,7 @@ int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
     }
 
     *pb = b;
+    ERR_clear_last_mark();
     return off;
  err:
     ERR_clear_last_mark();