]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
crypto/provider_conf.c: Fix possible memory leak
authorJiashengJiang <jiasheng@purdue.edu>
Mon, 5 May 2025 01:41:39 +0000 (21:41 -0400)
committerTomas Mraz <tomas@openssl.org>
Wed, 7 May 2025 09:50:54 +0000 (11:50 +0200)
Assign the return value of ossl_provider_info_add_to_store to added instead of
setting it directly to 1, in order to avoid a memory leak caused by entry not
being freed if ossl_provider_info_add_to_store() fails.

Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27472)

(cherry picked from commit 9884f1dc11675a5c4613339cfb92903c6ba6103f)

crypto/provider_conf.c

index 6a8b88e2e56da4633379f9648e11508e42fac407..b53ea3b1f8afad8dbcc6c2fe6c7b49da49e74967 100644 (file)
@@ -379,7 +379,7 @@ static int provider_conf_load(OSSL_LIB_CTX *libctx, const char *name,
             ok = provider_conf_params(NULL, &entry, NULL, value, cnf);
         if (ok >= 1 && (entry.path != NULL || entry.parameters != NULL)) {
             ok = ossl_provider_info_add_to_store(libctx, &entry);
-            added = 1;
+            added = ok;
         }
         if (added == 0)
             ossl_provider_info_clear(&entry);