--------------------- PatchSet 6215 Date: 2007/12/01 06:25:17 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Add protection to IP-cache reporting. - Protects from unexpected NULL pointers. - Fixes bug where neg-cached entry would not terminate its line with CR/NL Members: src/ipcache.cc:1.9.2.51->1.9.2.52 Index: squid3/src/ipcache.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ipcache.cc,v retrieving revision 1.9.2.51 retrieving revision 1.9.2.52 diff -u -r1.9.2.51 -r1.9.2.52 --- squid3/src/ipcache.cc 22 Oct 2007 06:45:07 -0000 1.9.2.51 +++ squid3/src/ipcache.cc 1 Dec 2007 06:25:17 -0000 1.9.2.52 @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.9.2.51 2007/10/22 06:45:07 amosjeffries Exp $ + * $Id: ipcache.cc,v 1.9.2.52 2007/12/01 06:25:17 amosjeffries Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -748,7 +748,15 @@ int count = i->addrs.count; char buf[MAX_IPSTRLEN]; - assert(i); + if(!sentry) { + debugs(14, 0, HERE << "CRITICAL: sentry is NULL!"); + } + + if(!i) { + debugs(14, 0, HERE << "CRITICAL: ipcache_entry is NULL!"); + storeAppendPrintf(sentry, "CRITICAL ERROR\n"); + return; + } storeAppendPrintf(sentry, " %-32.32s %c%c %6d %6d %2d(%2d)", hashKeyStr(&i->hash), @@ -759,6 +767,15 @@ (int) i->addrs.count, (int) i->addrs.badcount); + /** \par + * Negative-cached entries have no IPs listed. */ + if(i->flags.negcached) { + storeAppendPrintf(sentry, "\n"); + return; + } + + /** \par + * Cached entries have IPs listed with a BNF of: '-' ('OK'|'BAD') */ for (k = 0; k < count; k++) { /* Display tidy-up: IPv6 are so big make the list vertical */ if(k == 0)