From: Paul Gofman <pgofman@codeweavers.com> Fixes a regression introduced by d48e8d03bd679480c24671908f1d2e4c0851bd65. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59690 --- dlls/ws2_32/protocol.c | 17 ++++++++++++++++- dlls/ws2_32/tests/protocol.c | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index 9751c7a4d23..647409d84a3 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -802,7 +802,7 @@ static int __cdecl compare_routes_by_metric_asc( const void *left, const void *r */ static struct hostent *get_local_ips( char *hostname ) { - int numroutes = 0, i, j, default_routes = 0; + int numroutes = 0, i, j, default_routes = 0, matched_routes = 0; IP_ADAPTER_INFO *adapters = NULL, *k; struct hostent *hostlist = NULL; MIB_IPFORWARDTABLE *routes = NULL; @@ -876,10 +876,25 @@ static struct hostent *get_local_ips( char *hostname ) char *ip = k->IpAddressList.IpAddress.String; if (route_addrs[i].interface == k->Index) + { route_addrs[i].addr.s_addr = inet_addr(ip); + if (memcmp( &route_addrs[i].addr.s_addr, magic_loopback_addr, 4 )) ++matched_routes; + } } } + if (matched_routes) + { + for (i = 0; i < numroutes; ++i) + { + if (!memcmp( &route_addrs[i].addr.s_addr, magic_loopback_addr, 4 )) + { + --numroutes; + memmove( &route_addrs[i], &route_addrs[i + 1], sizeof(*route_addrs) * (numroutes - i) ); + --i; + } + } + } /* Allocate a hostent and enough memory for all the IPs, * including the NULL at the end of the list. */ diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c index 9c0e2f443ff..0e87ee04ce5 100644 --- a/dlls/ws2_32/tests/protocol.c +++ b/dlls/ws2_32/tests/protocol.c @@ -2644,7 +2644,7 @@ static void test_gethostbyname(void) if (local_ip) { - todo_wine ok(count == 1, "expected 127.0.0.1 to be the only IP returned\n"); + ok(count == 1, "expected 127.0.0.1 to be the only IP returned\n"); skip("Only the loopback address is present, skipping tests\n"); return; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10825