From: Heiko Hund Date: Thu, 30 Oct 2025 19:47:31 +0000 (+0100) Subject: iservice: check return value of MultiByteToWideChar X-Git-Tag: v2.7_rc1~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fdd4072541ba52e297c19672d3b1e7021d14bc91;p=thirdparty%2Fopenvpn.git 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@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34071.html Signed-off-by: Gert Doering --- diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c index e975cc758..d25d9c0e9 100644 --- a/src/openvpnserv/common.c +++ b/src/openvpnserv/common.c @@ -276,6 +276,10 @@ wchar_t * utf8to16_size(const char *utf8, int size) { int n = MultiByteToWideChar(CP_UTF8, 0, utf8, size, NULL, 0); + if (n == 0) + { + return NULL; + } wchar_t *utf16 = malloc(n * sizeof(wchar_t)); if (!utf16) {