]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
CMP client: fix three memory leaks in error handling of the polling mechanism added...
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Fri, 10 Oct 2025 22:57:01 +0000 (06:57 +0800)
committerDr. David von Oheimb <dev@ddvo.net>
Mon, 20 Oct 2025 07:36:29 +0000 (09:36 +0200)
These are in poll_for_response(), OSSL_CMP_try_certreq(), and OSSL_CMP_exec_certreq().

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/28840)

crypto/cmp/cmp_client.c

index 2001414241c186ea8b39cf54819a75772e721541..76e6771166c4a7aab0d294e91adcdcff1806068e 100644 (file)
@@ -369,7 +369,7 @@ static int poll_for_response(OSSL_CMP_CTX *ctx, int sleep, int rid,
         } else {
             ossl_cmp_info(ctx, "received final response after polling");
             if (!ossl_cmp_ctx_set1_first_senderNonce(ctx, NULL))
-                return 0;
+                goto err;
             break;
         }
     }
@@ -830,7 +830,7 @@ int OSSL_CMP_try_certreq(OSSL_CMP_CTX *ctx, int req_type,
             goto err;
 
         if (!save_senderNonce_if_waiting(ctx, rep, rid))
-            return 0;
+            goto err;
     } else {
         if (req_type < 0)
             return ossl_cmp_exchange_error(ctx, OSSL_CMP_PKISTATUS_rejection,
@@ -873,7 +873,7 @@ X509 *OSSL_CMP_exec_certreq(OSSL_CMP_CTX *ctx, int req_type,
         goto err;
 
     if (!save_senderNonce_if_waiting(ctx, rep, rid))
-        return 0;
+        goto err;
 
     if (cert_response(ctx, 1 /* sleep */, rid, &rep, NULL, req_type, rep_type)
         <= 0)