From: "cron2 (Code Review)" Date: Thu, 5 Mar 2026 08:00:59 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <6f63e51b3b46ae4e043684fc6fd63a381fc16ba1-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="2w3L3D84pxc="; 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 , plaisthos Cc: openvpn-devel --2w3L3D84pxc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#6) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1495?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos 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(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1495/6 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: newpatchset 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 --2w3L3D84pxc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #6 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by plaisthos

win32-util: Handle return value=
 from WideCharToMultiByte better

Handle the case where the return va= lue is zero
and avoid sign-compare warning.

Change-Id: I4ff7983a3= 3426fda9a138fe6e56a1c03522836d3
Signed-off-by: Frank Lichtenheld <fra= nk@...2641...>
Acked-by: Arne Schwabe <arne-openvpn@...1227...>=
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1495
Message-Id: = <20260304164928.15819-1-gert@...1296...>
URL: https://www.mail-arc= hive.com/openvpn-devel@lists.sourceforge.net/msg35906.html
Signed-off-by= : Gert Doering <gert@...1296...>
---
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/6<=
/pre>
-#=
if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-comp= are"
-#endif
-
const cha= r *
win_get_tempdir(void)
{
@@ -162,7 +157,14 @@

return NULL;
}

- if (WideCharToMultiByte(CP_UTF8, 0, wtmpdir, -1, NULL, 0, NULL, N= ULL) > 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 just i= n case */
+ if (re= t <=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 t= emporary directory. Path is too long."
= " Consider using --tmp-dir");
@@ -173,7 +1= 75,4 @@
return tmpdir;
}

-#if defined(__GN= UC__) || 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: newpatchset
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>
= --2w3L3D84pxc=--