]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix crash bug in HttpHeader::clean()
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 12 Feb 2014 08:51:26 +0000 (09:51 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 12 Feb 2014 08:51:26 +0000 (09:51 +0100)
src/HttpHeader.cc

index 571072a9d30afd6d88811d2742c09a1d6e506f81..de002db6bceb9e9cb45e667acbb9e965fa38fcda 100644 (file)
 
 #include <algorithm>
 
+/* XXX: the whole set of API managing the entries vector should be rethought
+ *      after the parse4r-ng effort is complete.
+ */
+
 /*
  * On naming conventions:
  *
@@ -437,8 +441,6 @@ HttpHeader::operator =(const HttpHeader &other)
 void
 HttpHeader::clean()
 {
-    HttpHeaderPos pos = HttpHeaderInitPos;
-    HttpHeaderEntry *e;
 
     assert(owner > hoNone && owner < hoEnd);
     debugs(55, 7, "cleaning hdr: " << this << " owner: " << owner);
@@ -464,18 +466,19 @@ HttpHeader::clean()
         HttpHeaderStats[owner].busyDestroyedCount += entries.size() > 0;
     } // if (owner <= hoReply)
 
-    while ((e = getEntry(&pos))) {
-        /* tmp hack to try to avoid coredumps */
-
+    for (std::vector<HttpHeaderEntry *>::iterator i = entries.begin(); i != entries.end(); ++i) {
+        HttpHeaderEntry *e = *i;
+        if (e == NULL)
+            continue;
         if (e->id < 0 || e->id >= HDR_ENUM_END) {
-            debugs(55, DBG_CRITICAL, "HttpHeader::clean BUG: entry[" << pos << "] is invalid (" << e->id << "). Ignored.");
+            debugs(55, DBG_CRITICAL, "BUG: invalid entry (" << e->id << "). Ignored.");
         } else {
             if (owner <= hoReply)
                 HttpHeaderStats[owner].fieldTypeDistr.count(e->id);
-            /* yes, this deletion leaves us in an inconsistent state */
             delete e;
         }
     }
+
     entries.clear();
     httpHeaderMaskInit(&mask, 0);
     len = 0;