From: "cron2 (Code Review)" Date: Thu, 30 Oct 2025 21:14:39 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., heiko@...515..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <9a2c6cc54a27b21b59ce8c2f8632c4e37681fc14-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="id9XtbA1kbY="; 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: d12fk Cc: plaisthos , flichtenheld , openvpn-devel --id9XtbA1kbY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/13= 06?usp=3Demail ) 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 Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1306 Message-Id: <20251030194736.2151-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 071.html Signed-off-by: Gert Doering --- M src/openvpnserv/common.c 1 file changed, 4 insertions(+), 0 deletions(-) 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: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I92804da010bab36cd0326759c04f955f2bda74de Gerrit-Change-Number: 1306 Gerrit-PatchSet: 2 Gerrit-Owner: d12fk Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --id9XtbA1kbY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

iservice: check return value of MultiByteToWideC=
har

If the first call to MultiByteToWideChar returns 0, something mu= st have
failed, because it returns the required buffer size including th= e
terminating zero. When it does return 0, just return NULL and indicate=
that the call to utf8to16(_size) failed.

Found by ZeroPath.
<= br>Reported-By: Joshua Rogers <contact@...2949...>
Change-Id: I928= 04da010bab36cd0326759c04f955f2bda74de
Signed-off-by: Heiko Hund <heik= o@...2662...>
Acked-by: Gert Doering <gert@...1296...>
Gerri= t URL: https://gerrit.openvpn.net/c/openvpn/+/1306
Message-Id: <20251= 030194736.2151-1-gert@...1296...>
URL: https://www.mail-archive.com/o= penvpn-devel@lists.sourceforge.net/msg34071.html
Signed-off-by: Gert Doe= ring <gert@...1296...>
---
M src/openvpnserv/common.c
1 file= changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c<=
br>index e975cc7..d25d9c0 100644
--- a/src/openvpnser= v/common.c
+++ b/src/openvpnserv/common.c
@= @ -276,6 +276,10 @@
utf8to16_size(const char *utf8, int si= ze)
{
int n =3D MultiByteToWideChar(C= P_UTF8, 0, utf8, size, NULL, 0);
+ if (n =3D=3D 0)
+ {
+ = return NULL;
+= }
wchar_t *utf16 =3D malloc(n * sizeof(wchar_t));<= /span>
if (!utf16)
{

To view, visit change 1306. To unsubscribe, or for help writin= g mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I92804da010bab36cd0326759c04= f955f2bda74de
Gerrit-Change-Number: 1306
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <heiko@...515...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --id9XtbA1kbY=--