From: Selva Nair Date: Wed, 3 Jan 2018 04:02:03 +0000 (-0500) Subject: Return NULL if GetAdaptersInfo fails X-Git-Tag: v2.4.5~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2b9bd80bab7ce56ada09b0df1c2baec8b029d93;p=thirdparty%2Fopenvpn.git Return NULL if GetAdaptersInfo fails - Currently a pointer to potentially uninitialized IP_ADAPTER_INFO struct is returned on error causing ill-defined behaviour. Signed-off-by: Selva Nair Acked-by: Steffan Karger Acked-by: Simon Rozman Message-Id: <1514952123-26616-1-git-send-email-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16139.html Signed-off-by: Gert Doering (cherry picked from commit 5050c5b1ec3f2aa04140ab83f2498b3329381ee4) --- diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 25831ce38..6e163489b 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -4178,15 +4178,12 @@ get_adapter_info_list(struct gc_arena *gc) else { pi = (PIP_ADAPTER_INFO) gc_malloc(size, false, gc); - if ((status = GetAdaptersInfo(pi, &size)) == NO_ERROR) - { - return pi; - } - else + if ((status = GetAdaptersInfo(pi, &size)) != NO_ERROR) { msg(M_INFO, "GetAdaptersInfo #2 failed (status=%u) : %s", (unsigned int)status, strerror_win32(status, gc)); + pi = NULL; } } return pi;