From: serassio <> Date: Sun, 23 Oct 2005 20:10:45 +0000 (+0000) Subject: Bug #1404: CNAME adresses remembered with wrong TTL X-Git-Tag: SQUID_3_0_PRE4~576 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d320a3ac149038006625c76534d22dfa9b11c37;p=thirdparty%2Fsquid.git Bug #1404: CNAME adresses remembered with wrong TTL should use the lowest TTL of the CNAME and A records, but was using only the TTL of the A records. Added too some forgotten things fron Bug #1222. Forward port of 2.5 patches. --- diff --git a/include/rfc1035.h b/include/rfc1035.h index f4852856eb..6f21a288ec 100644 --- a/include/rfc1035.h +++ b/include/rfc1035.h @@ -1,5 +1,5 @@ /* - * $Id: rfc1035.h,v 1.15 2005/05/10 10:39:56 hno Exp $ + * $Id: rfc1035.h,v 1.16 2005/10/23 14:10:45 serassio Exp $ * * AUTHOR: Duane Wessels * @@ -100,6 +100,7 @@ SQUIDCEXTERN int rfc1035_errno; SQUIDCEXTERN const char *rfc1035_error_message; #define RFC1035_TYPE_A 1 +#define RFC1035_TYPE_CNAME 5 #define RFC1035_TYPE_PTR 12 #define RFC1035_CLASS_IN 1 diff --git a/src/fqdncache.cc b/src/fqdncache.cc index cc1f323cfd..fbc47d5584 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.164 2005/04/18 21:52:42 hno Exp $ + * $Id: fqdncache.cc,v 1.165 2005/10/23 14:10:45 serassio Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -362,16 +362,23 @@ fqdncacheParse(fqdncache_entry *f, rfc1035_rr * answers, int nr, const char *err assert(answers); for (k = 0; k < nr; k++) { - if (answers[k].type != RFC1035_TYPE_PTR) - continue; - if (answers[k]._class != RFC1035_CLASS_IN) continue; - if (!answers[k].rdata[0]) - continue; + if (answers[k].type == RFC1035_TYPE_PTR) { + if (!answers[k].rdata[0]) { + debug(35, 2) ("fqdncacheParse: blank PTR record for '%s'\n", name); + continue; + } - f->names[f->name_count++] = xstrdup(answers[k].rdata); + if (strchr(answers[k].rdata, ' ')) { + debug(35, 2) ("fqdncacheParse: invalid PTR record '%s' for '%s'\n", answers[k].rdata, name); + continue; + } + + f->names[f->name_count++] = xstrdup(answers[k].rdata); + } else if (answers[k].type != RFC1035_TYPE_CNAME) + continue; if (ttl == 0 || (int) answers[k].ttl < ttl) ttl = answers[k].ttl; @@ -381,8 +388,7 @@ fqdncacheParse(fqdncache_entry *f, rfc1035_rr * answers, int nr, const char *err } if (f->name_count == 0) { - debug(35, 1) ("fqdncacheParse: No PTR record\n"); - f->error_message = xstrdup("No PTR record"); + debug(35, 1) ("fqdncacheParse: No PTR record for '%s'\n", name); return 0; } diff --git a/src/ipcache.cc b/src/ipcache.cc index a53c84ccb6..6c403e2a11 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.251 2005/04/18 21:52:42 hno Exp $ + * $Id: ipcache.cc,v 1.252 2005/10/23 14:10:45 serassio Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -420,23 +420,24 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m i->addrs.bad_mask = (unsigned char *)xcalloc(na, sizeof(unsigned char)); for (j = 0, k = 0; k < nr; k++) { - if (answers[k].type != RFC1035_TYPE_A) - continue; - if (answers[k]._class != RFC1035_CLASS_IN) continue; - if (answers[k].rdlength != 4) + if (answers[k].type == RFC1035_TYPE_A) { + if (answers[k].rdlength != 4) + continue; + + xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, 4); + + debug(14, 3) ("ipcacheParse: #%d %s\n", + j - 1, + inet_ntoa(i->addrs.in_addrs[j - 1])); + } else if (answers[k].type != RFC1035_TYPE_CNAME) continue; if (ttl == 0 || (int) answers[k].ttl < ttl) ttl = answers[k].ttl; - xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, 4); - - debug(14, 3) ("ipcacheParse: #%d %s\n", - j - 1, - inet_ntoa(i->addrs.in_addrs[j - 1])); } assert(j == na);