[ccan] [PATCH 1/2] net: Fix potential uninitialized use of variables in net_bind()

David Gibson david at gibson.dropbear.id.au
Mon Sep 23 21:37:01 EST 2013


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 at gibson.dropbear.id.au>
---
 ccan/net/net.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ccan/net/net.c b/ccan/net/net.c
index eef28e2..e84380f 100644
--- a/ccan/net/net.c
+++ b/ccan/net/net.c
@@ -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)
-- 
1.8.3.1



More information about the ccan mailing list