Fail silently when trying to convert IPv6 address to v4 family host
authorMartin Willi <martin@revosec.ch>
Wed, 22 Dec 2010 10:42:44 +0000 (11:42 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 5 Jan 2011 15:46:04 +0000 (16:46 +0100)
src/libstrongswan/utils/host.c

index 50e43d9..ffeebd0 100644 (file)
@@ -476,6 +476,10 @@ host_t *host_create_from_dns(char *string, int af, u_int16_t port)
        {
                return host_create_any_port(af ? af : AF_INET6, port);
        }
        {
                return host_create_any_port(af ? af : AF_INET6, port);
        }
+       if (af == AF_INET && strchr(string, ':'))
+       {       /* do not try to convert v6 addresses for v4 family */
+               return NULL;
+       }
 
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = af;
 
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = af;