From: "cron2 (Code Review)" Date: Thu, 5 Mar 2026 08:01:02 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <6f63e51b3b46ae4e043684fc6fd63a381fc16ba1-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="GtwrXpE8g7A="; 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: flichtenheld Cc: plaisthos , openvpn-devel --GtwrXpE8g7A= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/14= 95?usp=3Demail ) 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 Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1495 Message-Id: <20260304164928.15819-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 906.html Signed-off-by: Gert Doering --- M src/openvpn/win32-util.c 1 file changed, 8 insertions(+), 9 deletions(-) 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: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I4ff7983a33426fda9a138fe6e56a1c03522836d3 Gerrit-Change-Number: 1495 Gerrit-PatchSet: 6 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --GtwrXpE8g7A= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

win32-util: Handle return value from WideCharToM=
ultiByte better

Handle the case where the return value is zero
an= d avoid sign-compare warning.

Change-Id: I4ff7983a33426fda9a138fe6e5= 6a1c03522836d3
Signed-off-by: Frank Lichtenheld <frank@...2641...>=
Acked-by: Arne Schwabe <arne-openvpn@...1227...>
Gerrit URL: h= ttps://gerrit.openvpn.net/c/openvpn/+/1495
Message-Id: <2026030416492= 8.15819-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-= devel@lists.sourceforge.net/msg35906.html
Signed-off-by: Gert Doering &l= t;gert@...1296...>
---
M src/openvpn/win32-util.c
1 file change= d, 8 insertions(+), 9 deletions(-)

diff --git a/src/openvpn/win32-util.c b/src/openvpn/win32-util.c<=
br>index e60cbac..6fc3be4 100644
--- a/src/openvpn/wi= n32-util.c
+++ b/src/openvpn/win32-util.c
@= @ -146,11 +146,6 @@
return true;
}

-#if de= fined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare&q= uot;
-#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);
+ /* Acco= rding to documentation ret is never < 0, but include it here just in cas= e */
+ if (ret <= ;=3D 0)
+ {=
+ msg(M_WARN | M_ERR= NO, "Conversion of path name failed.");
+ return NULL;
+ }
+ if ((unsigned int)ret > sizeof(tmpdir))
<= span> {

msg(M_WARN, "Could not get tempor= ary 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 change 1495. To unsubscribe, or for help writing mail= filters, visit = settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4ff7983a33426fda9a138fe6e56= a1c03522836d3
Gerrit-Change-Number: 1495
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --GtwrXpE8g7A=--