]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #2447: Segfault on failed TCP DNS query
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Wed, 1 Oct 2008 20:25:41 +0000 (22:25 +0200)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Wed, 1 Oct 2008 20:25:41 +0000 (22:25 +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).

This patch apparently do not solve the segmentation fault, but at least
logs the condition properly.

src/dns_internal.cc

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