]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
io: preserve ipv4/ipv6 flags when resolving InetSocketAddress
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 17 May 2017 13:34:36 +0000 (14:34 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 14 Jul 2017 13:28:29 +0000 (14:28 +0100)
The original InetSocketAddress struct may have has_ipv4 and
has_ipv6 fields set, which will control both the ai_family
used during DNS resolution, and later use of the V6ONLY
flag.

Currently the standalone DNS resolver code drops the
has_ipv4 & has_ipv6 flags after resolving, which means
the later bind() code won't correctly set V6ONLY.

This fixes the following scenarios

  -vnc :0,ipv4=off
  -vnc :0,ipv6=on
  -vnc :::0,ipv4=off
  -vnc :::0,ipv6=on

which all mistakenly accepted IPv4 clients

Acked-by: Gerd Hoffmann <kraxel@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
io/dns-resolver.c

index 57a8896cbb2bb5cf7d109fab22f935dfbfbce48e..c072d121c3a47cf565007e1d7bd985ae5094fa88 100644 (file)
@@ -116,8 +116,10 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
             .numeric = true,
             .has_to = iaddr->has_to,
             .to = iaddr->to,
-            .has_ipv4 = false,
-            .has_ipv6 = false,
+            .has_ipv4 = iaddr->has_ipv4,
+            .ipv4 = iaddr->ipv4,
+            .has_ipv6 = iaddr->has_ipv6,
+            .ipv6 = iaddr->ipv6,
         };
 
         (*addrs)[i] = newaddr;