From e0f53cfe6ab8f0c52cfebdfafc4d03a692770228 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 19 May 2014 15:57:22 +0000 Subject: [PATCH] * net.cc (call_gaa): Fix setting pa_ret pointer in case of an error from GetAdaptersAddresses (CID 60218). (get_ifs): Add missing braces in AF_INET6 case which broke netmask computation. Break out of loop if prefix gets <= 0 (CID 59939). --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/net.cc | 14 ++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9b796856a..2a5724e46 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2014-05-19 Corinna Vinschen + + * net.cc (call_gaa): Fix setting pa_ret pointer in case of an error + from GetAdaptersAddresses (CID 60218). + (get_ifs): Add missing braces in AF_INET6 case which broke netmask + computation. Break out of loop if prefix gets <= 0 (CID 59939). + 2014-05-19 Corinna Vinschen * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 31. diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index ab36a30b4..010cf2435 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1673,7 +1673,7 @@ call_gaa (LPVOID param) if (ret != ERROR_SUCCESS) { free (pa0); - *p->pa_ret = pa0; + *p->pa_ret = NULL; } else *p->pa_ret = pa0; @@ -1685,7 +1685,7 @@ bool get_adapters_addresses (PIP_ADAPTER_ADDRESSES *pa_ret, ULONG family) { DWORD ret; - gaa_wa param = { family, pa_ret ?: NULL }; + gaa_wa param = { family, pa_ret }; if ((uintptr_t) ¶m >= (uintptr_t) 0x80000000L && wincap.has_gaa_largeaddress_bug ()) @@ -2080,10 +2080,12 @@ get_ifs (ULONG family) break; case AF_INET6: if_sin6 = (struct sockaddr_in6 *) &ifp->ifa_netmask; - for (cnt = 0; cnt < 4 && prefix; ++cnt, prefix -= 32) - if_sin6->sin6_addr.s6_addr32[cnt] = UINT32_MAX; - if (prefix < 32) - if_sin6->sin6_addr.s6_addr32[cnt] <<= 32 - prefix; + for (cnt = 0; cnt < 4 && prefix > 0; ++cnt, prefix -= 32) + { + if_sin6->sin6_addr.s6_addr32[cnt] = UINT32_MAX; + if (prefix < 32) + if_sin6->sin6_addr.s6_addr32[cnt] <<= 32 - prefix; + } break; } ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask;