[PATCH] ws2_32: Use unsigned interface index on interface_bind_check (try 2)
Bruno Jesus
bjesus at codeweavers.com
Wed May 10 20:46:31 CDT 2017
Try 2:
Change the way success is checked.
Original:
The exotic interface indexes used by linux for tun/ppp connections may cause problems resulting in interface_bind_check not finding the expected interface during loop.
Signed-off-by: Bruno Jesus <bjesus at codeweavers.com>
---
dlls/ws2_32/socket.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 9d27fabe1a..f6db83206a 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3671,7 +3671,8 @@ static void interface_bind_check(int fd, struct sockaddr_in *addr)
#if !defined(IP_BOUND_IF) && !defined(LINUX_BOUND_IF)
return;
#else
- int ifindex;
+ unsigned int ifindex;
+ int ret;
socklen_t len;
/* Check for IPv4, address 0.0.0.0 and UDP socket */
@@ -3680,15 +3681,14 @@ static void interface_bind_check(int fd, struct sockaddr_in *addr)
if (_get_fd_type(fd) != SOCK_DGRAM)
return;
- ifindex = -1;
len = sizeof(ifindex);
#if defined(IP_BOUND_IF)
- getsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &ifindex, &len);
+ ret = getsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &ifindex, &len);
#elif defined(LINUX_BOUND_IF)
- getsockopt(fd, IPPROTO_IP, IP_UNICAST_IF, &ifindex, &len);
- if (ifindex > 0) ifindex = ntohl(ifindex);
+ ret = getsockopt(fd, IPPROTO_IP, IP_UNICAST_IF, &ifindex, &len);
+ if (!ret) ifindex = ntohl(ifindex);
#endif
- if (ifindex > 0)
+ if (!ret)
{
PIP_ADAPTER_INFO adapters, adapter;
DWORD adap_size;
--
2.11.0
More information about the wine-patches
mailing list