mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 08:16:24 +01:00
Fix a FIXME in the WinXP inet_pton() implementation
https://bugzilla.gnome.org/show_bug.cgi?id=749912
This commit is contained in:
parent
a4c3ab58cc
commit
f9af40a133
@ -398,41 +398,29 @@ inet_pton (gint family,
|
|||||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa;
|
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa;
|
||||||
gint len = sizeof (sa);
|
gint len = sizeof (sa);
|
||||||
|
|
||||||
/* We need to make sure to not pass a string of the form
|
|
||||||
* "IPv4addr:port" or "[IPv6addr]:port" to WSAStringToAddress(),
|
|
||||||
* since it would accept them (returning both the address and the
|
|
||||||
* port), but we only want to accept standalone IP addresses. (In
|
|
||||||
* the IPv6 case, WINE actually only checks for the ']', not the
|
|
||||||
* '[', which is why we do the same here.)
|
|
||||||
*/
|
|
||||||
if (family != AF_INET && family != AF_INET6)
|
if (family != AF_INET && family != AF_INET6)
|
||||||
{
|
{
|
||||||
WSASetLastError (WSAEAFNOSUPPORT);
|
WSASetLastError (WSAEAFNOSUPPORT);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!strchr (addr_string, ':'))
|
|
||||||
{
|
/* WSAStringToAddress() will accept various not-an-IP-address
|
||||||
if (WSAStringToAddress ((LPTSTR) addr_string, AF_INET, NULL, (LPSOCKADDR) &sa, &len) == 0)
|
* strings like "127.0.0.1:80", "[1234::5678]:80", "127.1", etc.
|
||||||
{
|
*/
|
||||||
/* XXX: Figure out when WSAStringToAddress() accepts a IPv4 address but the
|
if (!g_hostname_is_ip_address (addr_string))
|
||||||
numbers-and-dots address is actually not complete. This code will be
|
return 0;
|
||||||
removed once XP/Server 2003 support is dropped... */
|
|
||||||
|
if (WSAStringToAddress ((LPTSTR) addr_string, family, NULL, (LPSOCKADDR) &sa, &len) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (family == AF_INET)
|
||||||
*(IN_ADDR *)addr = sin->sin_addr;
|
*(IN_ADDR *)addr = sin->sin_addr;
|
||||||
|
else
|
||||||
|
*(IN6_ADDR *)addr = sin6->sin6_addr;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!strchr (addr_string, ']'))
|
|
||||||
{
|
|
||||||
if (WSAStringToAddress ((LPTSTR) addr_string, AF_INET6, NULL, (LPSOCKADDR) &sa, &len) == 0)
|
|
||||||
{
|
|
||||||
*(IN6_ADDR *) addr = sin6->sin6_addr;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const gchar *
|
static const gchar *
|
||||||
inet_ntop (gint family,
|
inet_ntop (gint family,
|
||||||
|
Loading…
Reference in New Issue
Block a user