]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Don't leak sockets when getsockname fails.
authorSimon Kelley <simon@thekelleys.org.uk>
Mon, 4 Feb 2013 21:47:59 +0000 (21:47 +0000)
committerSimon Kelley <simon@thekelleys.org.uk>
Mon, 4 Feb 2013 21:47:59 +0000 (21:47 +0000)
src/dnsmasq.c

index 2ab1bdaac576626fd795d67cd4a32d7d8c002df9..00551a18671ac6ee2fadf952cc572e769fcc2e0b 100644 (file)
@@ -1345,10 +1345,15 @@ static void check_dns_listeners(fd_set *set, time_t now)
 
          while ((confd = accept(listener->tcpfd, NULL, NULL)) == -1 && errno == EINTR);
          
-         if (confd == -1 ||
-             getsockname(confd, (struct sockaddr *)&tcp_addr, &tcp_len) == -1)
+         if (confd == -1)
            continue;
 
+         if (getsockname(confd, (struct sockaddr *)&tcp_addr, &tcp_len) == -1)
+           {
+             close(confd);
+             continue;
+           }
+
           if (option_bool(OPT_NOWILD))
            iface = listener->iface; /* May be NULL */
           else