Fix missing check for return value of malloc'd buffer
PATCH 1/1 Fix missing check for return value of malloc'd buffer
From: Selva Nair <[email protected]...>
- Use utf8to16 from common.c for utf8 to wide conversion and check its return value
Signed-off-by Selva Nair <[email protected]...>
--- src/openvpnserv/interactive.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
src/openvpnserv/interactive.c +10 -8
@@ -547,15 +547,17 @@ static DWORD InterfaceLuid(const char *iface_name, PNET_LUID luid) {NETIO_STATUS status; -LPWSTR wide_name; -int n; - - n =MultiByteToWideChar (CP_UTF8 ,0 , iface_name,-1 ,NULL ,0 ); - wide_name =malloc (n *sizeof (WCHAR )); -MultiByteToWideChar (CP_UTF8 ,0 , iface_name,-1 , wide_name, n); - status =ConvertInterfaceAliasToLuid (wide_name, luid); -free (wide_name); +LPWSTR wide_name =utf8to16 (iface_name); +if (wide_name) + { + status =ConvertInterfaceAliasToLuid (wide_name, luid); +free (wide_name); + } +else + { + status =ERROR_OUTOFMEMORY ; + }return status; }
Signature · 1 line
2.6.2
ACK.
Patch is actually fairly trivial as soon as one recognizes that "utf8to16()" is one of our functions, which does exactly what the code removed here does - length check, malloc, malloc check, conversion-if-memory-allocated.
Your patch has been applied to the master and release/2.4 branch.
commit f3d389a2d2b87aeb649bfdccd596f485346a32c7 (master) commit 9ef03874bf0ca35348c58b4b21cb06cc49026efd (release/2.4)
Author: Selva Nair Date: Sun Oct 15 15:05:15 2017 -0400
Fix missing check for return value of malloc'd buffer
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg15641.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering