]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix a possible memleak in cms_main
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 3 Dec 2023 10:24:18 +0000 (11:24 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 12 Dec 2023 18:45:50 +0000 (19:45 +0100)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22918)

(cherry picked from commit 3457a550c64ab8009c7cd0175675ac140cab33c2)

apps/cms.c

index 12095b9641c8777fcb3e4a9900a16889f2bbd447..3994cb0fcd58cf5eb052ead31f301abbc9a380d8 100644 (file)
@@ -620,7 +620,8 @@ int cms_main(int argc, char **argv)
                                  "recipient certificate file");
                 if (cert == NULL)
                     goto end;
-                sk_X509_push(encerts, cert);
+                if (!sk_X509_push(encerts, cert))
+                    goto end;
                 cert = NULL;
             } else {
                 recipfile = opt_arg();
@@ -831,7 +832,8 @@ int cms_main(int argc, char **argv)
                              "recipient certificate file");
             if (cert == NULL)
                 goto end;
-            sk_X509_push(encerts, cert);
+            if (!sk_X509_push(encerts, cert))
+                goto end;
             cert = NULL;
         }
     }