mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-16 04:28:05 +02:00
gresolver.c: Windows: Fix IPv6 Address Handling
Check the IPv6 addresses on Windows, as we need to reject those that have brackets/ports around them as valid addresses in this form would have been accepted during the call to g_inet_address_new_from_string (). https://bugzilla.gnome.org/show_bug.cgi?id=730352
This commit is contained in:
parent
fecec08702
commit
b9c8cecc9d
@ -294,6 +294,7 @@ handle_ip_address (const char *hostname,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GInetAddress *addr;
|
GInetAddress *addr;
|
||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
struct in_addr ip4addr;
|
struct in_addr ip4addr;
|
||||||
#endif
|
#endif
|
||||||
@ -307,21 +308,30 @@ handle_ip_address (const char *hostname,
|
|||||||
|
|
||||||
*addrs = NULL;
|
*addrs = NULL;
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
|
||||||
|
/* Reject IPv6 addresses that have brackets ('[' or ']') and/or port numbers,
|
||||||
|
* as no valid addresses should contain these at this point.
|
||||||
|
* Non-standard IPv4 addresses would be rejected during the call to
|
||||||
|
* getaddrinfo() later.
|
||||||
|
*/
|
||||||
|
if (strrchr (hostname, '[') != NULL ||
|
||||||
|
strrchr (hostname, ']') != NULL)
|
||||||
|
#else
|
||||||
|
|
||||||
/* Reject non-standard IPv4 numbers-and-dots addresses.
|
/* Reject non-standard IPv4 numbers-and-dots addresses.
|
||||||
* g_inet_address_new_from_string() will have accepted any "real" IP
|
* g_inet_address_new_from_string() will have accepted any "real" IP
|
||||||
* address, so if inet_aton() succeeds, then it's an address we want
|
* address, so if inet_aton() succeeds, then it's an address we want
|
||||||
* to reject. This check is not necessary for Windows, as getaddrinfo()
|
* to reject.
|
||||||
* already rejects such IPv4 addresses on Windows.
|
|
||||||
*/
|
*/
|
||||||
#ifndef G_OS_WIN32
|
|
||||||
if (inet_aton (hostname, &ip4addr))
|
if (inet_aton (hostname, &ip4addr))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
|
g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
|
||||||
_("Error resolving '%s': %s"),
|
_("Error resolving '%s': %s"),
|
||||||
hostname, gai_strerror (EAI_NONAME));
|
hostname, gai_strerror (EAI_NONAME));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user