From 1981a52fdfc8c1acbf031a96c24b5e385d874227 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Fri, 7 Nov 2014 21:31:17 -0600 Subject: [PATCH] wmbiff: Fix connection leak. Patch by Arnaud Giersch . For more information, see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=663876 --- wmbiff/wmbiff/socket.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wmbiff/wmbiff/socket.c b/wmbiff/wmbiff/socket.c index ff2c819..7f7a9ec 100644 --- a/wmbiff/wmbiff/socket.c +++ b/wmbiff/wmbiff/socket.c @@ -58,6 +58,8 @@ static int ipv4_sock_connect(struct in_addr *address, short port) printf("socket() failed.\n"); return (-1); }; + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) + perror("fcntl(FD_CLOEXEC)"); addr.sin_family = AF_INET; addr.sin_addr.s_addr = *(u_long *) address; @@ -122,6 +124,8 @@ int sock_connect(const char *hostname, int port) fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (fd < 0) continue; + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) + perror("fcntl(FD_CLOEXEC)"); if (connect(fd, res->ai_addr, res->ai_addrlen) < 0) { close(fd); fd = -1;