]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed CheckQuickAbort2() FPE bug.
authorwessels <>
Thu, 9 Apr 1998 03:38:35 +0000 (03:38 +0000)
committerwessels <>
Thu, 9 Apr 1998 03:38:35 +0000 (03:38 +0000)
Fixed QuickAbort percent bug

src/cache_cf.cc
src/client_side.cc
src/defines.h

index 410616f1a9cfbe09a98ba10b8cd2ed7972830034..21dd516765cb1057dabc9f259ffd79487f6895d8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.271 1998/04/08 05:44:11 wessels Exp $
+ * $Id: cache_cf.cc,v 1.272 1998/04/08 21:38:35 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -1084,7 +1084,7 @@ parse_refreshpattern(refresh_t ** head)
     t->pattern = (char *) xstrdup(pattern);
     t->compiled_pattern = comp;
     t->min = min;
-    t->pct = pct;
+    t->pct = pct * QUICK_ABORT_100PCT / 100;
     t->max = max;
     t->next = NULL;
     while (*head)
index 4ff5826323b9ab0c498ef29f188de8111e6012a7..a852451d85ec21562ea90daa56142ecef2652a77 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.263 1998/04/08 19:28:47 wessels Exp $
+ * $Id: client_side.cc,v 1.264 1998/04/08 21:38:36 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -2026,9 +2026,9 @@ httpAccept(int sock, void *notused)
 static int
 CheckQuickAbort2(const clientHttpRequest * http)
 {
-    long curlen;
-    long minlen;
-    long expectlen;
+    int curlen;
+    int minlen;
+    int expectlen;
 
     if (!EBIT_TEST(http->request->flags, REQ_CACHABLE))
        return 1;
@@ -2037,8 +2037,8 @@ CheckQuickAbort2(const clientHttpRequest * http)
     if (http->entry->mem_obj == NULL)
        return 1;
     expectlen = http->entry->mem_obj->reply->content_length;
-    curlen = http->entry->mem_obj->inmem_hi;
-    minlen = Config.quickAbort.min;
+    curlen = (int) http->entry->mem_obj->inmem_hi;
+    minlen = (int) Config.quickAbort.min;
     if (minlen < 0)
        /* disabled */
        return 0;
@@ -2051,7 +2051,10 @@ CheckQuickAbort2(const clientHttpRequest * http)
     if ((expectlen - curlen) > Config.quickAbort.max)
        /* too much left to go */
        return 1;
-    if ((curlen / (expectlen / 128U)) > Config.quickAbort.pct)
+    if (expectlen < 128)
+       /* avoid FPE */
+       return 0;
+    if ((curlen / (expectlen / QUICK_ABORT_100PCT)) > Config.quickAbort.pct)
        /* past point of no return */
        return 0;
     return 1;
index 46b219337ebac0fcc69274f8934a1e07216b0d6c..7497d9c47ac65259fd4074ed8fe8f14bcf705709 100644 (file)
 
 #define PINGER_PAYLOAD_SZ 8192
 
+#define QUICK_ABORT_100PCT     128
+
 #define COUNT_INTERVAL 60
 /*
  * keep 60 minutes' worth of per-minute readings (+ current reading)