[Openvpn-devel] Fix missing check for return value of malloc'd buffer
Commit Message
From: Selva Nair <selva.nair@gmail.com>
- Use utf8to16 from common.c for utf8 to wide conversion and
check its return value
Signed-off-by: Selva Nair <selva.nair@gmail.com>
---
src/openvpnserv/interactive.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
Comments
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 <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1508094315-466-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15641.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
@@ -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;
}