]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
ssl_openssl.c: Prevent potential double-free
authorLev Stipakov <lev@openvpn.net>
Thu, 17 Apr 2025 13:46:30 +0000 (15:46 +0200)
committerGert Doering <gert@greenie.muc.de>
Thu, 17 Apr 2025 13:59:40 +0000 (15:59 +0200)
Fixes a potential double-free issue in tls_ctx_load_cert_uri()
by explicitly nullifying the pointer immediately after calling
OSSL_STORE_INFO_free(info).

This ensures that subsequent cleanup won't attempt to free the same
structure again.

Github: closes OpenVPN/openvpn#726

Change-Id: I4507be07cd5573b2117e837ef03187535a38a4b1
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <antonio@mandelbit.com>
Message-Id: <20250417134636.21279-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31478.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/ssl_openssl.c

index d1d5d3e3c63897600fc89061d97d4935ea6592a9..f7be50c50876b0857a8c7689d41f638e08ba3579 100644 (file)
@@ -1152,6 +1152,7 @@ tls_ctx_load_cert_uri(struct tls_root_ctx *tls_ctx, const char *uri)
         goto end;
     }
     OSSL_STORE_INFO_free(info);
+    info = NULL;
 
     /* iterate through the store and add extra certificates if any to the chain */
     while (!OSSL_STORE_eof(store_ctx))
@@ -1170,6 +1171,7 @@ tls_ctx_load_cert_uri(struct tls_root_ctx *tls_ctx, const char *uri)
             break;
         }
         OSSL_STORE_INFO_free(info);
+        info = NULL;
     }
 
 end: