]> 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:10:25 +0000 (19:10 +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)

crypto/asn1/a_d2i_fp.c

index df86d8b3fe13b6c98f2d14f6267920ccd2a35479..95c1b884c12934e4e8e5be2d1b39a0e38b40b7f3 100644 (file)
@@ -171,6 +171,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();
         }
         off += q - p;               /* end of data */
 
@@ -251,6 +252,7 @@ int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
     }
 
     *pb = b;
+    ERR_clear_last_mark();
     return (int)off;
  err:
     ERR_clear_last_mark();