From: "d12fk (Code Review)" Date: Sun, 26 Oct 2025 16:30:11 +0000 References: Reply-To: heiko@...515..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <30c0e371453964661c41379556e3fb72c162c28d-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="o5pvAlEDTqQ="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: iservice: check return value of MultiByteToWideChar List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --o5pvAlEDTqQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1306?usp=3Demail to review the following change. Change subject: iservice: check return value of MultiByteToWideChar ...................................................................... iservice: check return value of MultiByteToWideChar If the first call to MultiByteToWideChar returns 0, something must have failed, because it returns the required buffer size including the terminating zero. When it does return 0, just return NULL and indicate that the call to utf8to16(_size) failed. Found by ZeroPath. Reported-By: Joshua Rogers Change-Id: I92804da010bab36cd0326759c04f955f2bda74de Signed-off-by: Heiko Hund --- M src/openvpnserv/common.c 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/06/1306/1 diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c index e975cc7..d25d9c0 100644 --- a/src/openvpnserv/common.c +++ b/src/openvpnserv/common.c @@ -276,6 +276,10 @@ utf8to16_size(const char *utf8, int size) { int n =3D MultiByteToWideChar(CP_UTF8, 0, utf8, size, NULL, 0); + if (n =3D=3D 0) + { + return NULL; + } wchar_t *utf16 =3D malloc(n * sizeof(wchar_t)); if (!utf16) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1306?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: I92804da010bab36cd0326759c04f955f2bda74de Gerrit-Change-Number: 1306 Gerrit-PatchSet: 1 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --o5pvAlEDTqQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos.

d12fk would like plaisthos and flichtenheld to review t= his change.

V= iew Change

iservice: check return value of MultiByteTo=
WideChar

If the first call to MultiByteToWideChar returns 0, somethi= ng must have
failed, because it returns the required buffer size includi= ng the
terminating zero. When it does return 0, just return NULL and ind= icate
that the call to utf8to16(_size) failed.

Found by ZeroPath.=

Reported-By: Joshua Rogers <contact@...2949...>
Change-Id:= I92804da010bab36cd0326759c04f955f2bda74de
Signed-off-by: Heiko Hund <= ;heiko@...2662...>
---
M src/openvpnserv/common.c
1 file change= d, 4 insertions(+), 0 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/06/1306/1
diff --=
git a/src/openvpnserv/common.c b/src/openvpnserv/common.c
i= ndex e975cc7..d25d9c0 100644
--- a/src/openvpnserv/common.c=
+++ b/src/openvpnserv/common.c
@@ -276,6 += 276,10 @@
utf8to16_size(const char *utf8, int size)=
{
int n =3D MultiByteToWideChar(CP_UTF8, 0,= utf8, size, NULL, 0);
+ ret= urn NULL;
+ }
wchar_t *utf16 =3D malloc(n * sizeof(wchar_t));
= if (!utf16)
{

To view, visit change 1306. To unsubscribe, or for help writing mail fil= ters, visit sett= ings.

<= link itemprop=3D"url" href=3D"http://gerrit.openvpn.net/c/openvpn/+/1306?us= p=3Demail"/>
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I92804da010bab36cd0326759c04= f955f2bda74de
Gerrit-Change-Number: 1306
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <heiko@...515...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --o5pvAlEDTqQ=--