[ccan] [PATCH 7/7] net: Add check for failure of setsockopt()
Rusty Russell
rusty at rustcorp.com.au
Tue Apr 4 12:23:49 AEST 2017
David Gibson <david at gibson.dropbear.id.au> writes:
> make_listen_fd() didn't check for failure of setsockopt(). There's no
> real reason not to, since we have an obvious way to report an error to the
> caller.
>
> Found with Coverity Scan.
>
> Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
Great, all but the one I commented on look fine. Please apply...
Acked-by: Rusty Russell <rusty at rustcorp.com.au>
Thanks,
Rusty.
> ---
> ccan/net/net.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/ccan/net/net.c b/ccan/net/net.c
> index e919983..11c6b67 100644
> --- a/ccan/net/net.c
> +++ b/ccan/net/net.c
> @@ -238,7 +238,9 @@ static int make_listen_fd(const struct addrinfo *addrinfo)
> if (fd < 0)
> return -1;
>
> - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
> + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0)
> + goto fail;
> +
> if (bind(fd, addrinfo->ai_addr, addrinfo->ai_addrlen) != 0)
> goto fail;
>
> --
> 2.9.3
>
> _______________________________________________
> ccan mailing list
> ccan at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/ccan
More information about the ccan
mailing list