]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #2447: Segfault on failed TCP DNS query
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Thu, 2 Oct 2008 13:45:54 +0000 (15:45 +0200)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Thu, 2 Oct 2008 13:45:54 +0000 (15:45 +0200)
This patch makes Squid log the DNS failure if it fails to connect to
a DNS server over TCP. TCP is required if the DNS response do not fit
within the small DNS UDP packet size (ca 0.5kb).

src/dns_internal.cc

index f3b8d2403b0fe6523ce7bcfce9ec512660841236..03c254bc1324928c49f3d5571c892df35cc18647 100644 (file)
@@ -718,6 +718,8 @@ idnsInitVCConnected(int fd, comm_err_t status, int xerrno, void *data)
     nsvc * vc = (nsvc *)data;
 
     if (status != COMM_OK) {
+        char buf[MAX_IPSTRLEN];
+        debugs(78, 1, "idnsInitVCConnected: Failed to connect to nameserver " << nameservers[vc->ns].S.NtoA(buf,MAX_IPSTRLEN) << " using TCP!");
         comm_close(fd);
         return;
     }
@@ -744,6 +746,7 @@ idnsInitVC(int ns)
 
     nsvc *vc = cbdataAlloc(nsvc);
     nameservers[ns].vc = vc;
+    vc->ns = ns;
 
     IPAddress addr;
 
@@ -780,6 +783,13 @@ idnsSendQueryVC(idns_query * q, int ns)
 
     nsvc *vc = nameservers[ns].vc;
 
+    if (!vc) {
+        char buf[MAX_IPSTRLEN];
+        debugs(78, 1, "idnsSendQuery: Failed to initiate TCP connection to nameserver " << nameservers[ns].S.NtoA(buf,MAX_IPSTRLEN) << "!");
+
+        return;
+    }
+
     vc->queue->reset();
 
     short head = htons(q->sz);