From: "flichtenheld (Code Review)"
Date: Fri, 8 May 2026 11:27:25 +0000
References:
Reply-To: frank@...2641..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net
Message-ID: <978bf898f522619d2bba74c788709ee371c79ab9-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="7X56TQKHDXU="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: openvpnserv: Fix
memory leak when loading DLLs
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: plaisthos
Cc: openvpn-devel
--7X56TQKHDXU=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1670?usp=3Demail
to review the following change.
Change subject: openvpnserv: Fix memory leak when loading DLLs
......................................................................
openvpnserv: Fix memory leak when loading DLLs
Identified by cppcheck.
Change-Id: Iad3f0c36ac3795fa6a13f2d63bd00ad9c2c30d48
Signed-off-by: Frank Lichtenheld
---
M src/openvpnserv/interactive.c
1 file changed, 14 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/1670/1
diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index ace25b9..e25c511 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -1071,6 +1071,7 @@
publish_fn_t RtlPublishWnfStateData;
const DWORD WNF_GPOL_SYSTEM_CHANGES_HI =3D 0x0D891E2A;
const DWORD WNF_GPOL_SYSTEM_CHANGES_LO =3D 0xA3BC0875;
+ BOOL ret =3D FALSE;
HMODULE ntdll =3D LoadLibraryA("ntdll.dll");
if (ntdll =3D=3D NULL)
@@ -1081,16 +1082,19 @@
RtlPublishWnfStateData =3D (publish_fn_t)GetProcAddress(ntdll, "RtlPub=
lishWnfStateData");
if (RtlPublishWnfStateData =3D=3D NULL)
{
- return FALSE;
+ goto cleanup;
}
if (RtlPublishWnfStateData(WNF_GPOL_SYSTEM_CHANGES_LO, WNF_GPOL_SYSTEM=
_CHANGES_HI, 0, 0, 0, 0)
!=3D ERROR_SUCCESS)
{
- return FALSE;
+ goto cleanup;
}
- return TRUE;
+ ret =3D TRUE;
+cleanup:
+ FreeLibrary(ntdll);
+ return ret;
}
/**
@@ -1106,6 +1110,7 @@
unsigned int Length, INT64 ExplicitSc=
ope);
publish_fn_t RtlPublishWnfStateData;
const INT64 WNF_GPOL_SYSTEM_CHANGES =3D 0x0D891E2AA3BC0875;
+ BOOL ret =3D FALSE;
HMODULE ntdll =3D LoadLibraryA("ntdll.dll");
if (ntdll =3D=3D NULL)
@@ -1116,15 +1121,18 @@
RtlPublishWnfStateData =3D (publish_fn_t)GetProcAddress(ntdll, "RtlPub=
lishWnfStateData");
if (RtlPublishWnfStateData =3D=3D NULL)
{
- return FALSE;
+ goto cleanup;
}
if (RtlPublishWnfStateData(WNF_GPOL_SYSTEM_CHANGES, 0, 0, 0, 0) !=3D E=
RROR_SUCCESS)
{
- return FALSE;
+ goto cleanup;
}
- return TRUE;
+ ret =3D TRUE;
+cleanup:
+ FreeLibrary(ntdll);
+ return ret;
}
/**
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1670?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings?usp=3Demail
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iad3f0c36ac3795fa6a13f2d63bd00ad9c2c30d48
Gerrit-Change-Number: 1670
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
--7X56TQKHDXU=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is cur=
rently required from: plaisthos.
flichtenheld would like plaisthos to review this change.
V=
iew Change
openvpnserv: Fix memory leak when loading D=
LLs
Identified by cppcheck.
Change-Id: Iad3f0c36ac3795fa6a13f=
2d63bd00ad9c2c30d48
Signed-off-by: Frank Lichtenheld <frank@...2723...=
.>
---
M src/openvpnserv/interactive.c
1 file changed, 14 inser=
tions(+), 6 deletions(-)
git pull ssh://gerrit.o=
penvpn.net:29418/openvpn refs/changes/70/1670/1
diff --git a/src/op=
envpnserv/interactive.c b/src/openvpnserv/interactive.c
ind=
ex ace25b9..e25c511 100644
--- a/src/openvpnserv/interactiv=
e.c
+++ b/src/openvpnserv/interactive.c
@@ =
-1071,6 +1071,7 @@
publish_fn_t RtlPublishWnfStateData=
;
const DWORD WNF_GPOL_SYSTEM_CHANGES_HI =3D 0x0D891E2=
A;
const DWORD WNF_GPOL_SYSTEM_CHANGES_LO =3D 0xA3BC08=
75;
+ BOOL ret =3D=
FALSE;
HMODULE ntdll =3D LoadLibrar=
yA("ntdll.dll");
if (ntdll =3D=3D NULL)
@@ -1081,16 +1082,19 @@
RtlPublishWnfState=
Data =3D (publish_fn_t)GetProcAddress(ntdll, "RtlPublishWnfStateData&q=
uot;);
if (RtlPublishWnfStateData =3D=3D NULL)<=
br> {
- =
return FALSE;
+ =
goto cleanup;
}
=
if (RtlPublishWnfStateData(WNF_GPOL_SYSTEM_CHANGES_LO, WNF_GPOL_SYSTEM=
_CHANGES_HI, 0, 0, 0, 0)
!=3D ERROR_SUCCESS)
{
- =
return FALSE;
+ =
goto cleanup;
}
- return TRUE;
+ ret =3D TRUE;
+cleanup:
+ FreeLibrary(ntdll);
+ return ret;
}
/**
@@ -1106,6 +1110,7 @@
<=
span> unsigned int Length, INT64 Expli=
citScope);
publish_fn_t RtlPublishWnfStateData;=
const INT64 WNF_GPOL_SYSTEM_CHANGES =3D 0x0D891E2AA3BC0875;<=
/span>
+ BOOL ret =3D FAL=
SE;
HMODULE ntdll =3D LoadLibraryA(&=
quot;ntdll.dll");
if (ntdll =3D=3D NULL)@@ -1116,15 +1121,18 @@
RtlPublishWnfStateData=
=3D (publish_fn_t)GetProcAddress(ntdll, "RtlPublishWnfStateData"=
);
if (RtlPublishWnfStateData =3D=3D NULL)
<=
span> {
- re=
turn FALSE;
+ =
goto cleanup;
}
=
if (RtlPublishWnfStateData(WNF_GPOL_SYSTEM_CHANGES, 0, 0, 0, 0) !=3D ERROR=
_SUCCESS)
{
- return FALSE;
+ goto cleanup;
}
=
- return TRUE;
+ ret =3D TRUE;=
+cleanup:
+ FreeLibrary(ntdll);
+ return ret;
=
}
/**
<=
p>To view, visit change 1670. To unsubscribe, or for help writing mail filters=
, visit settings=
.
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iad3f0c36ac3795fa6a13f2d63bd=
00ad9c2c30d48
Gerrit-Change-Number: 1670
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...=
.>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...=
..1227...>
=
--7X56TQKHDXU=--