Skip to content

Commit fdd4072

Browse files
d12fkcron2
authored andcommitted
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 <[email protected]> Change-Id: I92804da010bab36cd0326759c04f955f2bda74de Signed-off-by: Heiko Hund <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1306 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg34071.html Signed-off-by: Gert Doering <[email protected]>
1 parent 9fa32e6 commit fdd4072

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/openvpnserv/common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ wchar_t *
276276
utf8to16_size(const char *utf8, int size)
277277
{
278278
int n = MultiByteToWideChar(CP_UTF8, 0, utf8, size, NULL, 0);
279+
if (n == 0)
280+
{
281+
return NULL;
282+
}
279283
wchar_t *utf16 = malloc(n * sizeof(wchar_t));
280284
if (!utf16)
281285
{

0 commit comments

Comments
 (0)