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

Rusty Russell rusty at rustcorp.com.au
Tue Sep 24 14:33:13 EST 2013


David Gibson <david at gibson.dropbear.id.au> writes:

> 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>

Thanks, applied!

Cheers,
Rusty.

> ---
>  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