From: Huw Davies Subject: [PATCH] iphlpapi: Always populate the friendly name. Message-Id: <20220105125519.49959-1-huw@codeweavers.com> Date: Wed, 5 Jan 2022 12:55:19 +0000 The GAA_FLAG_SKIP_FRIENDLY_NAME flag is essentially ignored. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48084 Signed-off-by: Huw Davies --- dlls/iphlpapi/iphlpapi_main.c | 11 ++++------- dlls/iphlpapi/tests/iphlpapi.c | 8 +++++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 15c4f067105..c94f869c9f9 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -1221,7 +1221,7 @@ static DWORD adapters_addresses_alloc( ULONG family, ULONG flags, IP_ADAPTER_ADD if (err) return err; needed = count * (sizeof(*aa) + ((CHARS_IN_GUID + 1) & ~1) + sizeof(stat->descr.String)); - if (!(flags & GAA_FLAG_SKIP_FRIENDLY_NAME)) needed += count * sizeof(rw->alias.String); + needed += count * sizeof(rw->alias.String); /* GAA_FLAG_SKIP_FRIENDLY_NAME is ignored */ aa = heap_alloc_zero( needed ); if (!aa) @@ -1243,12 +1243,9 @@ static DWORD adapters_addresses_alloc( ULONG family, ULONG flags, IP_ADAPTER_ADD if_counted_string_copy( (WCHAR *)str_ptr, ARRAY_SIZE(stat[i].descr.String), &stat[i].descr ); aa[i].Description = (WCHAR *)str_ptr; str_ptr += sizeof(stat[i].descr.String); - if (!(flags & GAA_FLAG_SKIP_FRIENDLY_NAME)) - { - if_counted_string_copy( (WCHAR *)str_ptr, ARRAY_SIZE(rw[i].alias.String), &rw[i].alias ); - aa[i].FriendlyName = (WCHAR *)str_ptr; - str_ptr += sizeof(rw[i].alias.String); - } + if_counted_string_copy( (WCHAR *)str_ptr, ARRAY_SIZE(rw[i].alias.String), &rw[i].alias ); + aa[i].FriendlyName = (WCHAR *)str_ptr; + str_ptr += sizeof(rw[i].alias.String); aa[i].PhysicalAddressLength = rw[i].phys_addr.Length; if (aa[i].PhysicalAddressLength > sizeof(aa[i].PhysicalAddress)) aa[i].PhysicalAddressLength = 0; memcpy( aa[i].PhysicalAddress, rw[i].phys_addr.Address, aa[i].PhysicalAddressLength ); diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 2adacd36b48..12da629c30c 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -1580,6 +1580,12 @@ static void test_GetAdaptersAddresses(void) ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret); if (ret != ERROR_BUFFER_OVERFLOW) return; + /* GAA_FLAG_SKIP_FRIENDLY_NAME is ignored */ + osize = 0x7fffffff; + ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, NULL, &osize); + ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret); + ok(osize == size, "expected %d, got %d\n", size, osize); + ptr = HeapAlloc(GetProcessHeap(), 0, size); ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, ptr, &size); ok(!ret, "expected ERROR_SUCCESS got %u\n", ret); @@ -1589,7 +1595,7 @@ static void test_GetAdaptersAddresses(void) size *= 2; osize = size; ptr = HeapAlloc(GetProcessHeap(), 0, osize); - ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, NULL, ptr, &osize); + ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, ptr, &osize); ok(!ret, "expected ERROR_SUCCESS got %u\n", ret); ok(osize == size, "expected %d, got %d\n", size, osize); -- 2.23.0