From aba53d4c40280d368ea8efd4f5e80a03b2e5ac72 Mon Sep 17 00:00:00 2001 From: Henrik Nordstrom Date: Wed, 1 Oct 2008 22:25:41 +0200 Subject: [PATCH] Bug #2447: Segfault on failed TCP DNS query 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dns_internal.cc b/src/dns_internal.cc index f3b8d2403b..a32b35030c 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -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); -- 2.47.2