From: "stipa (Code Review)"
Date: Thu, 17 Apr 2025 11:30:44 +0000
References:
Reply-To: lstipakov@...277..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net, frank@...2641...
Message-ID:
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="tzsUY1Sb/iI="; 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
--tzsUY1Sb/iI=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/942?usp=3Demail
to review the following change.
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.
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/1
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: 1
Gerrit-Owner: stipa
Gerrit-Reviewer: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
Gerrit-Attention: flichtenheld
Gerrit-MessageType: newchange
--tzsUY1Sb/iI=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld, plaisthos.
stipa would like plaisthos and flichtenheld to review t=
his change.
Vi=
ew Change
ssl_openssl.c: Prevent potential double-free Fixes a p=
otential double-free issue in tls_ctx_load_cert_uri() by explicitly null=
ifying the pointer immediately after calling OSSL_STORE_INFO_free(info). This ensures that subsequent cleanup won't attempt to free the sam=
e pointer again. Change-Id: I4507be07cd5573b2117e837ef03187535a38a4b=
1 Signed-off-by: Lev Stipakov <lev@...515...> --- M src/open=
vpn/ssl_openssl.c 1 file changed, 7 insertions(+), 1 deletion(-) =
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/942/1
=
diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.cindex d1d5d3e..524cc00 100644 --- a/src/openv=
pn/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 certifica=
tes if any to the chain */ while (!OSSL_STORE_eof(stor=
e_ctx)) @@ -1170,6 +1171,7 @@ =
break; } OSSL_STORE_INFO_=
free(info); + =
info =3D NULL; } en=
d: @@ -1184,7 +1186,11 @@ } =
UI_destroy_method(ui_method); - OSSL_STORE_INFO_free(info); =
+ if (info) + {+ OSSL_STORE_INFO_free(info); =
+ info =3D NULL; <=
br>+ } =
OSSL_STORE_close(store_ctx); #else /* defined(HAVE_OPENSSL=
_STORE_API */ ASSERT(0); =
pre> To view, visit change 942 . To unsubscribe, or for help writing mail filte=
rs, visit settings .
<=
div itemscope itemtype=3D"http://schema.org/EmailMessage">
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4507be07cd5573b2117e837ef03=
187535a38a4b1
Gerrit-Change-Number: 942
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <lstipakov@...277...>=
;
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
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-MessageType: newchange
--tzsUY1Sb/iI=--