From: hno <> Date: Fri, 28 Sep 2007 06:22:37 +0000 (+0000) Subject: Audited the code for possible >2GB issues X-Git-Tag: SQUID_3_0_RC1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e62bd58224d151d42e0dc3c3afee4bef05805d1;p=thirdparty%2Fsquid.git Audited the code for possible >2GB issues object sizes need to use int64_t, not ssize_t --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index a603775aef..7069d187f1 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.135 2007/09/21 11:41:52 amosjeffries Exp $ + * $Id: HttpHeader.cc,v 1.136 2007/09/28 00:22:37 hno Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -566,7 +566,7 @@ HttpHeader::parse(const char *header_start, const char *header_end) if (e->id == HDR_CONTENT_LENGTH && (e2 = findEntry(e->id)) != NULL) { if (e->value.cmp(e2->value.buf()) != 0) { - ssize_t l1, l2; + int64_t l1, l2; debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2, "WARNING: found two conflicting content-length headers in {" << getStringPrefix(header_start, header_end) << "}"); @@ -575,11 +575,11 @@ HttpHeader::parse(const char *header_start, const char *header_end) goto reset; } - if (!httpHeaderParseSize(e->value.buf(), &l1)) { + if (!httpHeaderParseOffset(e->value.buf(), &l1)) { debugs(55, 1, "WARNING: Unparseable content-length '" << e->value.buf() << "'"); delete e; continue; - } else if (!httpHeaderParseSize(e2->value.buf(), &l2)) { + } else if (!httpHeaderParseOffset(e2->value.buf(), &l2)) { debugs(55, 1, "WARNING: Unparseable content-length '" << e2->value.buf() << "'"); delById(e2->id); } else if (l1 > l2) { diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index 1a158e4904..9a79afb431 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderTools.cc,v 1.62 2007/08/13 17:20:51 hno Exp $ + * $Id: HttpHeaderTools.cc,v 1.63 2007/09/28 00:22:37 hno Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -332,16 +332,6 @@ httpHeaderParseInt(const char *start, int *value) return 1; } -int -httpHeaderParseSize(const char *start, ssize_t * value) -{ - int v; - const int res = httpHeaderParseInt(start, &v); - assert(value); - *value = res ? v : 0; - return res; -} - int httpHeaderParseOffset(const char *start, int64_t * value) { diff --git a/src/Store.h b/src/Store.h index 6a2d1a740b..5020befedb 100644 --- a/src/Store.h +++ b/src/Store.h @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.36 2007/08/13 17:20:51 hno Exp $ + * $Id: Store.h,v 1.37 2007/09/28 00:22:37 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -323,7 +323,6 @@ storeAppendPrintf(StoreEntry *, const char *,...) PRINTF_FORMAT_ARG2; SQUIDCEXTERN void storeAppendPrintf(); #endif SQUIDCEXTERN void storeAppendVPrintf(StoreEntry *, const char *, va_list ap); -SQUIDCEXTERN ssize_t objectLen(const StoreEntry * e); SQUIDCEXTERN int storeTooManyDiskFilesOpen(void); SQUIDCEXTERN void storeHeapPositionUpdate(StoreEntry *, SwapDir *); SQUIDCEXTERN void storeSwapFileNumberSet(StoreEntry * e, sfileno filn); diff --git a/src/SwapDir.h b/src/SwapDir.h index 4cb7baab0a..0768372679 100644 --- a/src/SwapDir.h +++ b/src/SwapDir.h @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.h,v 1.14 2007/08/13 17:20:51 hno Exp $ + * $Id: SwapDir.h,v 1.15 2007/09/28 00:22:37 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -145,7 +145,7 @@ virtual size_t maxSize() const { return max_size;} virtual void updateSize(int64_t size, int sign); /* migrated from store_dir.cc */ - bool objectSizeIsAcceptable(ssize_t objsize) const; + bool objectSizeIsAcceptable(int64_t objsize) const; protected: void parseOptions(int reconfiguring); diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 814a8fab12..c8b61a555c 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.520 2007/09/01 05:56:37 amosjeffries Exp $ + * $Id: cache_cf.cc,v 1.521 2007/09/28 00:22:37 hno Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2327,11 +2327,13 @@ dump_b_size_t(StoreEntry * entry, const char *name, size_t var) storeAppendPrintf(entry, "%s %d %s\n", name, (int) var, B_BYTES_STR); } +#if UNUSED_CODE static void dump_kb_size_t(StoreEntry * entry, const char *name, size_t var) { storeAppendPrintf(entry, "%s %d %s\n", name, (int) var, B_KBYTES_STR); } +#endif static void dump_b_int64_t(StoreEntry * entry, const char *name, int64_t var) @@ -2359,11 +2361,13 @@ parse_b_size_t(size_t * var) parseBytesLine(var, B_BYTES_STR); } +#if UNUSED_CODE static void parse_kb_size_t(size_t * var) { parseBytesLine(var, B_KBYTES_STR); } +#endif static void parse_b_int64_t(int64_t * var) diff --git a/src/cf.data.pre b/src/cf.data.pre index a7341f61c0..a26fd83827 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.474 2007/09/27 16:15:23 rousskov Exp $ +# $Id: cf.data.pre,v 1.475 2007/09/28 00:22:37 hno Exp $ # # SQUID Web Proxy Cache http://www.squid-cache.org/ # ---------------------------------------------------------- @@ -2679,7 +2679,7 @@ DOC_END NAME: store_avg_object_size COMMENT: (kbytes) -TYPE: kb_size_t +TYPE: kb_int64_t DEFAULT: 13 KB LOC: Config.Store.avgObjectSize DOC_START diff --git a/src/client_side.cc b/src/client_side.cc index cfc7ad38d1..279ce06541 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.766 2007/09/23 09:18:10 serassio Exp $ + * $Id: client_side.cc,v 1.767 2007/09/28 00:22:38 hno Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1549,7 +1549,7 @@ ClientSocketContext::initiateClose(const char *reason) ConnStateData::Pointer conn = http->getConn(); if (conn != NULL) { - if (const ssize_t expecting = conn->bodySizeLeft()) { + if (const int64_t expecting = conn->bodySizeLeft()) { debugs(33, 5, HERE << "ClientSocketContext::initiateClose: " << "closing, but first " << conn << " needs to read " << expecting << " request body bytes with " << @@ -2103,7 +2103,7 @@ clientAfterReadingRequests(int fd, ConnStateData::Pointer &conn, int do_next_rea */ if (fd_table[fd].flags.socket_eof) { - if ((ssize_t) conn->in.notYetUsed < conn->bodySizeLeft()) { + if ((int64_t)conn->in.notYetUsed < conn->bodySizeLeft()) { /* Partial request received. Abort client connection! */ debugs(33, 3, "clientAfterReadingRequests: FD " << fd << " aborted, partial request"); comm_close(fd); @@ -2323,7 +2323,7 @@ connOkToAddRequest(ConnStateData::Pointer &conn) * Report on the number of bytes of body content that we * know are yet to be read on this connection. */ -ssize_t +int64_t ConnStateData::bodySizeLeft() { // XXX: this logic will not work for chunked requests with unknown sizes @@ -3213,7 +3213,7 @@ ConnStateData::reading(bool const newBool) BodyPipe::Pointer -ConnStateData::expectRequestBody(size_t size) +ConnStateData::expectRequestBody(int64_t size) { bodyPipe = new BodyPipe(this); bodyPipe->setBodySize(size); diff --git a/src/client_side.h b/src/client_side.h index 7ad3af9ecb..6497b2c248 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -1,6 +1,6 @@ /* - * $Id: client_side.h,v 1.24 2007/08/27 12:50:42 hno Exp $ + * $Id: client_side.h,v 1.25 2007/09/28 00:22:38 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -161,7 +161,7 @@ public: size_t allocatedSize; } in; - ssize_t bodySizeLeft(); + int64_t bodySizeLeft(); /* * Is this connection based authentication? if so what type it @@ -203,7 +203,7 @@ public: bool closing() const; void startClosing(const char *reason); - BodyPipe::Pointer expectRequestBody(size_t size); + BodyPipe::Pointer expectRequestBody(int64_t size); virtual void noteMoreBodySpaceAvailable(BodyPipe &); virtual void noteBodyConsumerAborted(BodyPipe &); diff --git a/src/protos.h b/src/protos.h index 11429288ca..333463e3bc 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.549 2007/09/25 13:24:59 hno Exp $ + * $Id: protos.h,v 1.550 2007/09/28 00:22:38 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -243,7 +243,6 @@ SQUIDCEXTERN int strListIsSubstr(const String * list, const char *s, char del); SQUIDCEXTERN int strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos); SQUIDCEXTERN const char *getStringPrefix(const char *str, const char *end); SQUIDCEXTERN int httpHeaderParseInt(const char *start, int *val); -SQUIDCEXTERN int httpHeaderParseSize(const char *start, ssize_t * sz); SQUIDCEXTERN int httpHeaderParseOffset(const char *start, int64_t * off); #if STDC_HEADERS SQUIDCEXTERN void diff --git a/src/store_dir.cc b/src/store_dir.cc index 4003ccdf49..d9c28a1010 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir.cc,v 1.162 2007/08/13 17:20:51 hno Exp $ + * $Id: store_dir.cc,v 1.163 2007/09/28 00:22:38 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -153,7 +153,7 @@ StoreController::create() * ie any-sized-object swapdirs. This is a good thing. */ bool -SwapDir::objectSizeIsAcceptable(ssize_t objsize) const +SwapDir::objectSizeIsAcceptable(int64_t objsize) const { /* * If the swapdir's max_obj_size is -1, then it definitely can diff --git a/src/structs.h b/src/structs.h index ffc1846c89..1f8a278c48 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.564 2007/09/21 15:16:42 hno Exp $ + * $Id: structs.h,v 1.565 2007/09/28 00:22:38 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -475,7 +475,7 @@ struct _SquidConfig struct { int objectsPerBucket; - size_t avgObjectSize; + int64_t avgObjectSize; int64_t maxObjectSize; int64_t minObjectSize; size_t maxInMemObjSize;