From: "flichtenheld (Code Review)" Date: Tue, 27 Jan 2026 11:31:10 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <536fa401e8850a562bea142c5c84bf4fc51d2c18-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="+KBY273OC2M="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: win32-util: Handle return value from WideCharToMultiByte better List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --+KBY273OC2M= 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/+/1495?usp=3Demail to review the following change. Change subject: win32-util: Handle return value from WideCharToMultiByte be= tter ...................................................................... win32-util: Handle return value from WideCharToMultiByte better Handle the case where the return value is zero and avoid sign-compare warning. Change-Id: I4ff7983a33426fda9a138fe6e56a1c03522836d3 Signed-off-by: Frank Lichtenheld --- M src/openvpn/win32-util.c 1 file changed, 8 insertions(+), 9 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1495/1 diff --git a/src/openvpn/win32-util.c b/src/openvpn/win32-util.c index e60cbac..6fc3be4 100644 --- a/src/openvpn/win32-util.c +++ b/src/openvpn/win32-util.c @@ -146,11 +146,6 @@ return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - const char * win_get_tempdir(void) { @@ -162,7 +157,14 @@ return NULL; } - if (WideCharToMultiByte(CP_UTF8, 0, wtmpdir, -1, NULL, 0, NULL, NULL) = > sizeof(tmpdir)) + int ret =3D WideCharToMultiByte(CP_UTF8, 0, wtmpdir, -1, NULL, 0, NULL= , NULL); + /* According to documentation ret is never < 0, but include it here ju= st in case */ + if (ret <=3D 0) + { + msg(M_WARN | M_ERRNO, "Conversion of path name failed."); + return NULL; + } + if ((unsigned int)ret > sizeof(tmpdir)) { msg(M_WARN, "Could not get temporary directory. Path is too long." " Consider using --tmp-dir"); @@ -173,7 +175,4 @@ return tmpdir; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif #endif /* _WIN32 */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1495?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: I4ff7983a33426fda9a138fe6e56a1c03522836d3 Gerrit-Change-Number: 1495 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --+KBY273OC2M= 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

win32-util: Handle return value from WideCh=
arToMultiByte better

Handle the case where the return value is zero<= br>and avoid sign-compare warning.

Change-Id: I4ff7983a33426fda9a138= fe6e56a1c03522836d3
Signed-off-by: Frank Lichtenheld <frank@...2723...= .>
---
M src/openvpn/win32-util.c
1 file changed, 8 insertions(= +), 9 deletions(-)

git pull ssh://gerrit.openvpn=
.net:29418/openvpn refs/changes/95/1495/1
diff --git a/src/openvpn/=
win32-util.c b/src/openvpn/win32-util.c
index e60cbac..6fc3= be4 100644
--- a/src/openvpn/win32-util.c
+= ++ b/src/openvpn/win32-util.c
@@ -146,11 +146,6 @@ return true;
}

-#if defined(__GNUC__) || defined(_= _clang__)
-#pragma GCC = diagnostic push
-#pragm= a GCC diagnostic ignored "-Wsign-compare"
-#endif
-
const char *
win_get_te= mpdir(void)
{
@@ -162,7 +157,14 @@<= br> return NULL;
}

- if (WideCharToMultiBy= te(CP_UTF8, 0, wtmpdir, -1, NULL, 0, NULL, NULL) > sizeof(tmpdir))
+ int ret =3D WideCharT= oMultiByte(CP_UTF8, 0, wtmpdir, -1, NULL, 0, NULL, NULL);
+ /* According to documentation ret= is never < 0, but include it here just in case */
+ if (ret <=3D 0)
+ {
+ msg(M_WARN | M_ERRNO, "Conversion of pa= th name failed.");
+ return NULL;
+ }
+ if ((= unsigned int)ret > sizeof(tmpdir))
{
msg(M_WARN, "Could not get temporary directory. Path is too= long."

" Consider using --= tmp-dir");
@@ -173,7 +175,4 @@
re= turn tmpdir;
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic po= p
-#endif
#endif /* _WIN32 */


To view, visit = change 1= 495. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4ff7983a33426fda9a138fe6e56= a1c03522836d3
Gerrit-Change-Number: 1495
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...>
= --+KBY273OC2M=--