From: "stipa (Code Review)" Date: Thu, 17 Apr 2025 11:43:37 +0000 In-Reply-To: References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., antonio@...2726... Message-ID: <75d6cd7beff42d777557ea23c9ef6c5353882ce6-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Y+LS5lGtFqg="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: ssl_openssl.c: Prevent potential double-free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --Y+LS5lGtFqg= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, ordex, plaisthos, stipa. Hello flichtenheld, ordex, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/942?usp=3Demail to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review-1 by ordex Change subject: ssl_openssl.c: Prevent potential double-free ...................................................................... ssl_openssl.c: Prevent potential double-free Fixes a potential double-free issue in tls_ctx_load_cert_uri() by explicitly nullifying the pointer immediately after calling OSSL_STORE_I= NFO_free(info). This ensures that subsequent cleanup won't attempt to free the same pointer= again. GitHub: #726 Change-Id: I4507be07cd5573b2117e837ef03187535a38a4b1 Signed-off-by: Lev Stipakov --- M src/openvpn/ssl_openssl.c 1 file changed, 7 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/942/2 diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index d1d5d3e..524cc00 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -1152,6 +1152,7 @@ goto end; } OSSL_STORE_INFO_free(info); + info =3D NULL; /* iterate through the store and add extra certificates if any to the = chain */ while (!OSSL_STORE_eof(store_ctx)) @@ -1170,6 +1171,7 @@ break; } OSSL_STORE_INFO_free(info); + info =3D NULL; } end: @@ -1184,7 +1186,11 @@ } UI_destroy_method(ui_method); - OSSL_STORE_INFO_free(info); + if (info) + { + OSSL_STORE_INFO_free(info); + info =3D NULL; + } OSSL_STORE_close(store_ctx); #else /* defined(HAVE_OPENSSL_STORE_API */ ASSERT(0); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/942?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I4507be07cd5573b2117e837ef03187535a38a4b1 Gerrit-Change-Number: 942 Gerrit-PatchSet: 2 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Attention: ordex Gerrit-Attention: stipa Gerrit-MessageType: newpatchset --Y+LS5lGtFqg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, ordex, plaisthos, s= tipa.

stipa uploaded patch set #2 to this change.

View Change

The following approvals got outdated and were removed: Code-Review-1 by ordex

ssl_openssl.c: Prevent potential double-free

= Fixes a potential double-free issue in tls_ctx_load_cert_uri()
by explic= itly nullifying the pointer immediately after calling OSSL_STORE_INFO_free(= info).

This ensures that subsequent cleanup won't attempt to fre= e the same pointer again.

GitHub: #726

Change-Id: I4507be07cd= 5573b2117e837ef03187535a38a4b1
Signed-off-by: Lev Stipakov <lev@...1387...= 5...>
---
M src/openvpn/ssl_openssl.c
1 file changed, 7 inserti= ons(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/ope=
nvpn refs/changes/42/942/2
diff --git a/src/openvpn/ssl_openssl.c b=
/src/openvpn/ssl_openssl.c
index d1d5d3e..524cc00 100644
--- a/src/openvpn/ssl_openssl.c
+++ b/src/ope= nvpn/ssl_openssl.c
@@ -1152,6 +1152,7 @@
= goto end;
}
OSSL_STORE_INF= O_free(info);
+ in= fo =3D NULL;

/* iterate through the = store and add extra certificates if any to the chain */
= while (!OSSL_STORE_eof(store_ctx))
@@ -1170,6 +1171,7 @@<= /span>
break;
}
OSSL_STORE_INFO_free(info);

+ info =3D NULL;
}
end:
@@ -1184,7 +1186,11 @@
}

UI_destroy_method= (ui_method);
- OSSL_= STORE_INFO_free(info);
+ = {
+ OSSL_STOR= E_INFO_free(info);
+ = info =3D NULL;
+ }
OSSL_STORE_close(store_ctx);
= #else /* defined(HAVE_OPENSSL_STORE_API */
ASSERT(0);<= /span>

To view, visit change 942. To unsubscribe, o= r for help writing mail filters, visit settings.

=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4507be07cd5573b2117e837ef03= 187535a38a4b1
Gerrit-Change-Number: 942
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: ordex <antonio@...2726...&= gt;
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: ordex <antonio@...2726...= >
Gerrit-Attention: stipa <lstipakov@...1663...= .>
Gerrit-MessageType: newpatchset
--Y+LS5lGtFqg=--