From: wessels <> Date: Thu, 9 Apr 1998 03:38:35 +0000 (+0000) Subject: Fixed CheckQuickAbort2() FPE bug. X-Git-Tag: SQUID_3_0_PRE1~3559 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4efca7da294beff6f7c870ee4359721f20526a82;p=thirdparty%2Fsquid.git Fixed CheckQuickAbort2() FPE bug. Fixed QuickAbort percent bug --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 410616f1a9..21dd516765 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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) diff --git a/src/client_side.cc b/src/client_side.cc index 4ff5826323..a852451d85 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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; diff --git a/src/defines.h b/src/defines.h index 46b219337e..7497d9c47a 100644 --- a/src/defines.h +++ b/src/defines.h @@ -196,6 +196,8 @@ #define PINGER_PAYLOAD_SZ 8192 +#define QUICK_ABORT_100PCT 128 + #define COUNT_INTERVAL 60 /* * keep 60 minutes' worth of per-minute readings (+ current reading)