]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix potential leak in error path in cert_response()
authorNiels Dossche <niels.dossche@ugent.be>
Wed, 22 Jan 2025 13:35:25 +0000 (14:35 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 25 Feb 2025 14:48:50 +0000 (15:48 +0100)
get1_cert_status() returns an object that must be freed,
but the error path does not do that.
Fix it by adding a call to X509_free() in the error path.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26513)

crypto/cmp/cmp_client.c

index b88c005c85459849b721266cd4b2b8e5d024b034..cc2a06d77e0277ac56814ef8dd095fb31cfbe274 100644 (file)
@@ -736,8 +736,10 @@ static int cert_response(OSSL_CMP_CTX *ctx, int sleep, int rid,
         ERR_add_error_data(1, "; cannot extract certificate from response");
         return 0;
     }
-    if (!ossl_cmp_ctx_set0_newCert(ctx, cert))
+    if (!ossl_cmp_ctx_set0_newCert(ctx, cert)) {
+        X509_free(cert);
         return 0;
+    }
 
     /*
      * if the CMP server returned certificates in the caPubs field, copy them