From: Henrik Nordstrom Date: Thu, 2 Oct 2008 13:45:54 +0000 (+0200) Subject: Bug #2447: Segfault on failed TCP DNS query X-Git-Tag: SQUID_3_1_0_1~50^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=445962f35bfe99d2eb0c18289b1956c64017ffd5;p=thirdparty%2Fsquid.git 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). --- diff --git a/src/dns_internal.cc b/src/dns_internal.cc index f3b8d2403b..03c254bc13 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -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);