BUG/MEDIUM: dns: fix multiple double close on fd in dns.c
authorEmeric Brun <ebrun@haproxy.com>
Mon, 15 Feb 2021 14:20:19 +0000 (15:20 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 15 Feb 2021 14:42:44 +0000 (15:42 +0100)
It seems that fd_delete perform the close of the file descriptor
Se we must not close the fd once again after that.

This should fix issues #1128, #1130 and #1131

src/dns.c

index 58c68d7..cb30bff 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -117,7 +117,6 @@ int dns_send_nameserver(struct dns_nameserver *ns, void *buf, size_t len)
                        }
                        ns->counters->snd_error++;
                        fd_delete(fd);
-                       close(fd);
                        dgram->t.sock.fd = -1;
                        return -1;
                }
@@ -164,7 +163,6 @@ ssize_t dns_recv_nameserver(struct dns_nameserver *ns, void *data, size_t size)
                                return 0;
                        }
                        fd_delete(fd);
-                       close(fd);
                        dgram->t.sock.fd = -1;
                        return -1;
                }
@@ -342,7 +340,6 @@ static void dns_resolve_send(struct dgram_conn *dgram)
                        }
                        ns->counters->snd_error++;
                        fd_delete(fd);
-                       close(fd);
                        fd = dgram->t.sock.fd = -1;
                        goto out;
                }