From: "cron2 (Code Review)" Date: Tue, 28 Oct 2025 14:05:51 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., selva.nair@...277..., openvpn-devel@lists.sourceforge.net, frank@...2641..., lstipakov@...277... Message-ID: <5387c2c1077d1f5281b98614892e246771ef0f14-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="BLLxJB4HX3s="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Canonicalize config_dir before comparing with the config file location List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: selvanair , plaisthos , flichtenheld , stipa Cc: openvpn-devel --BLLxJB4HX3s= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/1318?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos, Code-Review+2 by stipa Change subject: Canonicalize config_dir before comparing with the config fi= le location ...................................................................... Canonicalize config_dir before comparing with the config file location Found by ZeroPath Change-Id: I8e884c00cb94f97a612056e8dca74d821a6d6386 Signed-off-by: Selva Nair Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1318 Message-Id: <20251028101642.11874-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33= 923.html Signed-off-by: Gert Doering --- M src/openvpnserv/CMakeLists.txt M src/openvpnserv/validate.c 2 files changed, 17 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/18/1318/2 diff --git a/src/openvpnserv/CMakeLists.txt b/src/openvpnserv/CMakeLists.txt index 340b904..a92ee08 100644 --- a/src/openvpnserv/CMakeLists.txt +++ b/src/openvpnserv/CMakeLists.txt @@ -6,6 +6,11 @@ add_executable(openvpnserv) +include(CheckSymbolExists) + +# Some old versions of mingw does not have PATHCCH_OPTIONS enums -- add a = check +check_symbol_exists(PATHCCH_ENSURE_TRAILING_SLASH pathcch.h HAVE_PATHCCH_E= NSURE_TRAILING_SLASH) + set(MC_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/mc) target_include_directories(openvpnserv PRIVATE @@ -31,7 +36,7 @@ ) target_link_libraries(openvpnserv advapi32.lib userenv.lib iphlpapi.lib fwpuclnt.lib rpcrt4.lib - shlwapi.lib netapi32.lib ws2_32.lib ntdll.lib ole32.lib) + shlwapi.lib netapi32.lib ws2_32.lib ntdll.lib ole32.lib pathcch.lib) if (MINGW) target_compile_options(openvpnserv PRIVATE -municode) target_link_options(openvpnserv PRIVATE -municode) diff --git a/src/openvpnserv/validate.c b/src/openvpnserv/validate.c index 59d5b86..2187fb5 100644 --- a/src/openvpnserv/validate.c +++ b/src/openvpnserv/validate.c @@ -25,6 +25,11 @@ #include #include #include +#include + +#ifndef HAVE_PATHCCH_ENSURE_TRAILING_SLASH +#define PATHCCH_ENSURE_TRAILING_SLASH 0x20 +#endif static const WCHAR *white_list[] =3D { L"auth-retry", @@ -61,7 +66,7 @@ { WCHAR tmp[MAX_PATH]; const WCHAR *config_file =3D NULL; - const WCHAR *config_dir =3D NULL; + WCHAR config_dir[MAX_PATH]; /* convert fname to full path */ if (PathIsRelativeW(fname)) @@ -74,9 +79,12 @@ config_file =3D fname; } - config_dir =3D s->config_dir; + /* canonicalize config_dir and add trailing slash before comparison */ + HRESULT res =3D PathCchCanonicalizeEx(config_dir, _countof(config_dir)= , s->config_dir, + PATHCCH_ENSURE_TRAILING_SLASH); - if (wcsncmp(config_dir, config_file, wcslen(config_dir)) =3D=3D 0 + if (res =3D=3D S_OK + && wcsncmp(config_dir, config_file, wcslen(config_dir)) =3D=3D 0 && wcsstr(config_file + wcslen(config_dir), L"..") =3D=3D NULL) { return TRUE; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1318?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I8e884c00cb94f97a612056e8dca74d821a6d6386 Gerrit-Change-Number: 1318 Gerrit-PatchSet: 2 Gerrit-Owner: selvanair Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-Reviewer: stipa Gerrit-CC: openvpn-devel --BLLxJB4HX3s= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #2 to the change originally created by selvanair.<= /p>

Vi= ew Change

The following approvals got outdated and were removed: Code-Review+2 by plaisthos, Code-Review+2 by stipa

Canonic=
alize config_dir before comparing with the config file location

Foun= d by ZeroPath

Change-Id: I8e884c00cb94f97a612056e8dca74d821a6d6386Signed-off-by: Selva Nair <selva.nair@...277...>
Acked-by: Arne = Schwabe <arne-openvpn@...1227...>
Gerrit URL: https://gerrit.openv= pn.net/c/openvpn/+/1318
Message-Id: <20251028101642.11874-1-gert@...1386...= 296...>
URL: https://www.mail-archive.com/openvpn-devel@...1535...= orge.net/msg33923.html
Signed-off-by: Gert Doering <gert@...1296...&g= t;
---
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/validate= .c
2 files changed, 17 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/18/131=
8/2
diff --git a/src/openvpnserv/CMakeLists.txt b/src/openvpnserv/C=
MakeLists.txt
index 340b904..a92ee08 100644
--- a/src/openvpnserv/CMakeLists.txt
+++ b/src/openvpnserv= /CMakeLists.txt
@@ -6,6 +6,11 @@
add_executable(openvpnserv)

+include(CheckSymbolExists)
+
+# Some old versions of mingw does not have PATHCCH_O= PTIONS enums -- add a check
+check_symbol_exists(PATHCCH_ENSURE_TRAILING_SLASH pathcch.h HAVE_PA= THCCH_ENSURE_TRAILING_SLASH)
+
set(MC_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/mc)

target_include_directories(openvpnserv PR= IVATE
@@ -31,7 +36,7 @@
)
target_link_libraries(openvpnserv

advapi32.lib us= erenv.lib iphlpapi.lib fwpuclnt.lib rpcrt4.lib
- shlwapi.lib netapi32.lib ws2_32.lib ntdll.lib = ole32.lib)
+ shlwa= pi.lib netapi32.lib ws2_32.lib ntdll.lib ole32.lib pathcch.lib)
<= span> if (MINGW)
target_compile_options(openvpnserv PR= IVATE -municode)
target_link_options(openvpnserv PRIVA= TE -municode)
diff --git a/src/openvpnserv/validate.c b/src= /openvpnserv/validate.c
index 59d5b86..2187fb5 100644

--- a/src/openvpnserv/validate.c
+++ b/src/openv= pnserv/validate.c
@@ -25,6 +25,11 @@
#incl= ude <lmaccess.h>
#include <shlwapi.h> #include <lm.h>
+#include <pathcch.h>
+
+#= ifndef HAVE_PATHCCH_ENSURE_TRAILING_SLASH
+#define PATHCCH_ENSURE_TRAILING_SLASH 0x20
= +#endif

static const WCHAR *white_list[] =3D {
L&q= uot;auth-retry",
@@ -61,7 +66,7 @@
{<= /span>
WCHAR tmp[MAX_PATH];
const WCHAR = *config_file =3D NULL;
= - const WCHAR *config_dir =3D NULL;
+ WCHAR config_dir[MAX_PATH];
=
/* convert fname to full path */
if (Pa= thIsRelativeW(fname))
@@ -74,9 +79,12 @@
= config_file =3D fname;
}

- config_dir =3D s->c= onfig_dir;
+ /* ca= nonicalize config_dir and add trailing slash before comparison */+ HRESULT res =3D PathCchCa= nonicalizeEx(config_dir, _countof(config_dir), s->config_dir,
= + = PATHCCH_ENSURE_TRAILING_SLASH);

- if (wcsncmp(config_dir, config_fi= le, wcslen(config_dir)) =3D=3D 0

+ if (res =3D=3D S_OK
+ && wcsncmp(config_dir, config_file, wcslen= (config_dir)) =3D=3D 0
&& wcsstr(config_fi= le + wcslen(config_dir), L"..") =3D=3D NULL)
= {
return TRUE;

<= p>To view, visit change 1318. To unsubscribe, or for help writing mail filters= , visit settings= .

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e884c00cb94f97a612056e8dca= 74d821a6d6386
Gerrit-Change-Number: 1318
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <selva.nair@...1354...= ..>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-Reviewer: stipa <lstipakov@...277...= >
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --BLLxJB4HX3s=--