]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4131: SIGSEGV at store.cc:962 content_length > store_maxobjsize
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 1 Dec 2014 11:59:46 +0000 (03:59 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 1 Dec 2014 11:59:46 +0000 (03:59 -0800)
src/Store.h
src/store.cc

index 33975195ca71b98699530ad6ba404c18052fa0fd..445dcfc8cfd3d831ba27ae9dedfee09310c25b12 100644 (file)
@@ -226,6 +226,8 @@ protected:
     void transientsAbandonmentCheck();
 
 private:
+    bool checkTooBig() const;
+
     static MemAllocator *pool;
 
     unsigned short lock_count;         /* Assume < 65536! */
index d576194fe18b64ad397c8f2d6887abb531849eb5..1a70777fe3f88bab4de8fdb2be31fc9458ba6c1a 100644 (file)
@@ -932,6 +932,18 @@ StoreEntry::checkTooSmall()
     return 0;
 }
 
+bool
+StoreEntry::checkTooBig() const
+{
+    if (mem_obj->endOffset() > store_maxobjsize)
+        return true;
+
+    if (getReply()->content_length < 0)
+        return false;
+
+    return (getReply()->content_length > store_maxobjsize);
+}
+
 // TODO: move "too many open..." checks outside -- we are called too early/late
 bool
 StoreEntry::checkCachable()
@@ -963,9 +975,12 @@ StoreEntry::checkCachable()
             debugs(20, 3, "StoreEntry::checkCachable: NO: negative cached");
             ++store_check_cachable_hist.no.negative_cached;
             return 0;           /* avoid release call below */
-        } else if ((getReply()->content_length > 0 &&
-                    getReply()->content_length > store_maxobjsize) ||
-                   mem_obj->endOffset() > store_maxobjsize) {
+        } else if (!mem_obj || !getReply()) {
+            // XXX: In bug 4131, we forgetHit() without mem_obj, so we need
+            // this segfault protection, but how can we get such a HIT?
+            // TODO: add store_check_cachable_hist.no.parts if this check stays
+            debugs(20, 2, "StoreEntry::checkCachable: NO: missing parts: " << *this);
+        } else if (checkTooBig()) {
             debugs(20, 2, "StoreEntry::checkCachable: NO: too big");
             ++store_check_cachable_hist.no.too_big;
         } else if (checkTooSmall()) {