]> 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:46 +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)

(cherry picked from commit 7f015c909ee3480a59d4fe828c3da22c7a55a2f4)

crypto/asn1/a_d2i_fp.c

index 0c88c98106811e21ef5cccd965cc0a0d4d9d02d5..10fe54afdab917364eae942ed2d1f02e457b015e 100644 (file)
@@ -169,6 +169,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 */
 
@@ -249,6 +250,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();