[openssl] master update

Dr. Paul Dale pauli at openssl.org
Sat May 15 01:43:56 UTC 2021


The branch master has been updated
       via  a113826eac59a1e897c679beaa5934542c46952d (commit)
      from  647a5dbf10227d65919b49d078da4eaca313f921 (commit)


- Log -----------------------------------------------------------------
commit a113826eac59a1e897c679beaa5934542c46952d
Author: Matt Caswell <matt at openssl.org>
Date:   Thu May 13 15:13:22 2021 +0100

    Fix a memleak on an error path in the pkcs12 test helpers
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15269)

-----------------------------------------------------------------------

Summary of changes:
 test/helpers/pkcs12.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/test/helpers/pkcs12.c b/test/helpers/pkcs12.c
index bdc8585535..ab877bca00 100644
--- a/test/helpers/pkcs12.c
+++ b/test/helpers/pkcs12.c
@@ -278,11 +278,9 @@ void start_contentinfo(PKCS12_BUILDER *pb)
 
 void end_contentinfo(PKCS12_BUILDER *pb)
 {
-    if (pb->success) {
-        if (pb->bags && !TEST_true(PKCS12_add_safe(&pb->safes, pb->bags, -1, 0, NULL))) {
+    if (pb->success && pb->bags != NULL) {
+        if (!TEST_true(PKCS12_add_safe(&pb->safes, pb->bags, -1, 0, NULL)))
             pb->success = 0;
-            return;
-        }
     }
     sk_PKCS12_SAFEBAG_pop_free(pb->bags, PKCS12_SAFEBAG_free);
     pb->bags = NULL;
@@ -291,19 +289,16 @@ void end_contentinfo(PKCS12_BUILDER *pb)
 
 void end_contentinfo_encrypted(PKCS12_BUILDER *pb, const PKCS12_ENC *enc)
 {
-    if (pb->success) {
-        if (pb->bags) {
-            if (legacy) {
-                if (!TEST_true(PKCS12_add_safe(&pb->safes, pb->bags, enc->nid, enc->iter, enc->pass))) {
-                    pb->success = 0;
-                    return;
-                }
-            } else {
-                if (!TEST_true(PKCS12_add_safe_ex(&pb->safes, pb->bags, enc->nid, enc->iter, enc->pass, test_ctx, test_propq))) {
-                    pb->success = 0;
-                    return;
-                }
-            }
+    if (pb->success && pb->bags != NULL) {
+        if (legacy) {
+            if (!TEST_true(PKCS12_add_safe(&pb->safes, pb->bags, enc->nid,
+                                           enc->iter, enc->pass)))
+                pb->success = 0;
+        } else {
+            if (!TEST_true(PKCS12_add_safe_ex(&pb->safes, pb->bags, enc->nid,
+                                              enc->iter, enc->pass, test_ctx,
+                                              test_propq)))
+                pb->success = 0;
         }
     }
     sk_PKCS12_SAFEBAG_pop_free(pb->bags, PKCS12_SAFEBAG_free);


More information about the openssl-commits mailing list