Repository : ssh://git@open-mesh.org/batmand
On branch : master
commit 4de9e4b5b707631d065571a437391c2a0de11052 Author: Sven Eckelmann sven@narfation.org Date: Tue Jun 17 21:56:01 2014 +0200
batmand: Free socket when setsockopt failed
client_to_gw_tun calls setsockopt which can fail. In this case it jumps to the error handling and cleanup code but doesn't close the udp_sock. This has to be done to avoid leaking of file descriptors.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Elektra Wagenrad onelektra@gmx.net
4de9e4b5b707631d065571a437391c2a0de11052 posix/tunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/posix/tunnel.c b/posix/tunnel.c index 08c56a2..8e7611b 100644 --- a/posix/tunnel.c +++ b/posix/tunnel.c @@ -201,7 +201,7 @@ void *client_to_gw_tun(void *arg) sock_opts = 1; if (setsockopt(udp_sock, SOL_SOCKET, SO_REUSEADDR, &sock_opts, sizeof(sock_opts)) < 0) { debug_output(0, "Error - can't set options on udp socket: %s\n", strerror(errno)); - goto out; + goto udp_out; }
if (bind(udp_sock, (struct sockaddr *)&my_addr, sizeof(struct sockaddr_in)) < 0) {