net: Fix potential uninitialized use of variables in net_bind()
authorDavid Gibson <david@gibson.dropbear.id.au>
Mon, 23 Sep 2013 11:37:01 +0000 (21:37 +1000)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 24 Sep 2013 04:32:56 +0000 (14:02 +0930)
If the list of addrinfos give to net_bind() contains only IPv4 or only
IPv6 addresses, then the ipv4 and ipv6 variables may be used uninitialized.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/net/net.c

index eef28e2fd7100ed8f94179c8015c3cbc2dccd582..e84380fff96f27a885d05618a46b6d1d2d46cc2c 100644 (file)
@@ -204,7 +204,8 @@ fail:
 
 int net_bind(const struct addrinfo *addrinfo, int fds[2])
 {
-       const struct addrinfo *ipv6, *ipv4;
+       const struct addrinfo *ipv6 = NULL;
+       const struct addrinfo *ipv4 = NULL;
        unsigned int num;
 
        if (addrinfo->ai_family == AF_INET)