From: serassio <> Date: Sun, 13 Feb 2005 22:49:50 +0000 (+0000) Subject: Bug #1234: util.c:612: xstrndup: Assertion `n' failed. X-Git-Tag: SQUID_3_0_PRE4~870 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=470cd749764c7a1673c1d8d115c915b9b0ee8243;p=thirdparty%2Fsquid.git Bug #1234: util.c:612: xstrndup: Assertion `n' failed. Forward port of 2.5 patch. --- diff --git a/src/comm.cc b/src/comm.cc index 5165ce9f43..842d2069ea 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.399 2004/12/20 16:30:35 robertc Exp $ + * $Id: comm.cc,v 1.400 2005/02/13 15:49:50 serassio Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1392,9 +1392,6 @@ ConnectStateData::defaults() S.sin_family = AF_INET; S.sin_addr = in_addr; S.sin_port = htons(port); - - if (Config.onoff.log_fqdn) - fqdncache_gethostbyaddr(S.sin_addr, FQDN_LOOKUP_IF_MISS); } void diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 20d8377458..aa239a47b7 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.162 2004/12/20 16:30:35 robertc Exp $ + * $Id: fqdncache.cc,v 1.163 2005/02/13 15:49:50 serassio Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -368,7 +368,10 @@ fqdncacheParse(fqdncache_entry *f, rfc1035_rr * answers, int nr, const char *err if (answers[k]._class != RFC1035_CLASS_IN) continue; - f->names[f->name_count++] = xstrndup(answers[k].rdata, answers[k].rdlength); + if (!answers[k].rdata[0]) + continue; + + f->names[f->name_count++] = xstrdup(answers[k].rdata); if (ttl == 0 || (int) answers[k].ttl < ttl) ttl = answers[k].ttl; diff --git a/src/ipcache.cc b/src/ipcache.cc index d3a70c52bd..7ac28dd8bf 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.249 2004/12/20 16:30:35 robertc Exp $ + * $Id: ipcache.cc,v 1.250 2005/02/13 15:49:50 serassio Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -402,6 +402,11 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m if (answers[k]._class != RFC1035_CLASS_IN) continue; + if (answers[k].rdlength != 4) { + debug(14, 1)("ipcacheParse: Invalid IP address in response to '%s'\n", name); + continue; + } + na++; } @@ -421,11 +426,12 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m if (answers[k]._class != RFC1035_CLASS_IN) continue; + if (answers[k].rdlength != 4) + continue; + if (ttl == 0 || (int) answers[k].ttl < ttl) ttl = answers[k].ttl; - assert(answers[k].rdlength == 4); - xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, 4); debug(14, 3) ("ipcacheParse: #%d %s\n",