]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #1182: Fix Resource leak (socket), at startup.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 13 Dec 2016 12:55:55 +0000 (12:55 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 13 Dec 2016 12:55:55 +0000 (12:55 +0000)
git-svn-id: file:///svn/unbound/trunk@3961 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/listen_dnsport.c

index 47ed3027d9ef875cb269b80f1e0e279cdf7aa9d4..35024a3cb3f84dd5af768868c89ca20ad8b29bd5 100644 (file)
@@ -1,3 +1,6 @@
+13 December 2016: Wouter
+       - Fix #1182: Fix Resource leak (socket), at startup.
+
 9 December 2016: Wouter
        - Fix #1176: stack size too small for Alpine Linux.
 
index 6637483b9dcf9c915b47a317ad90a79dbb7abdb5..129700fb85b9c50322b9a6406f8a72db67b5258c 100644 (file)
@@ -720,28 +720,37 @@ create_local_accept_sock(const char *path, int* noproto)
                /* The socket already exists and cannot be removed */
                log_err("Cannot remove old local socket %s (%s)",
                        path, strerror(errno));
-               return -1;
+               goto err;
        }
 
        if (bind(s, (struct sockaddr *)&usock,
                (socklen_t)sizeof(struct sockaddr_un)) == -1) {
                log_err("Cannot bind local socket %s (%s)",
                        path, strerror(errno));
-               return -1;
+               goto err;
        }
 
        if (!fd_set_nonblock(s)) {
                log_err("Cannot set non-blocking mode");
-               return -1;
+               goto err;
        }
 
        if (listen(s, TCP_BACKLOG) == -1) {
                log_err("can't listen: %s", strerror(errno));
-               return -1;
+               goto err;
        }
 
        (void)noproto; /*unused*/
        return s;
+
+err:
+#ifndef USE_WINSOCK
+       close(s);
+#else
+       closesocket(s);
+#endif
+       return -1;
+
 #else
        (void)path;
        log_err("Local sockets are not supported");