]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
asn_mime: Harden multi_split() against pushing NULL if a section is empty
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 11 Oct 2025 12:25:46 +0000 (20:25 +0800)
committerTomas Mraz <tomas@openssl.org>
Tue, 18 Nov 2025 16:53:40 +0000 (17:53 +0100)
Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28881)

crypto/asn1/asn_mime.c

index c9bdfd98c848f24f56cfee81c3ac4fde31af676e..f3511fedd7de604301c084cd35d491f890b06bbc 100644 (file)
@@ -669,6 +669,12 @@ static int multi_split(BIO *bio, int flags, const char *bound, STACK_OF(BIO) **r
             first = 1;
             part++;
         } else if (state == 2) {
+            if (bpart == NULL) {
+                bpart = BIO_new(BIO_s_mem());
+                if (bpart == NULL)
+                    return 0;
+                BIO_set_mem_eof_return(bpart, 0);
+            }
             if (!sk_BIO_push(parts, bpart)) {
                 BIO_free(bpart);
                 return 0;