]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Audited the code for possible >2GB issues
authorhno <>
Fri, 28 Sep 2007 06:22:37 +0000 (06:22 +0000)
committerhno <>
Fri, 28 Sep 2007 06:22:37 +0000 (06:22 +0000)
object sizes need to use int64_t, not ssize_t

src/HttpHeader.cc
src/HttpHeaderTools.cc
src/Store.h
src/SwapDir.h
src/cache_cf.cc
src/cf.data.pre
src/client_side.cc
src/client_side.h
src/protos.h
src/store_dir.cc
src/structs.h

index a603775aef580399d4266dd42f40bfd06a948342..7069d187f1025cc1ad4473de019a29898cf2255d 100644 (file)
@@ -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) {
index 1a158e49046b618b380f1b7759c60bde47a82db4..9a79afb4315779e2a9417f83ad81836e3aadc50f 100644 (file)
@@ -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)
 {
index 6a2d1a740b0711fa023de2dc761765881de63009..5020befedb8f464a79b82af7311309fb6a3ddb98 100644 (file)
@@ -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);
index 4cb7baab0a65f89facb0cb48fa634be673f20ae2..07683726798323a2f1b3870035dfd03b325c16f7 100644 (file)
@@ -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);
index 814a8fab1250d38a8eeedc11e78d79cbe7d3fa60..c8b61a555cda65da0205b89cf320fd669d22788f 100644 (file)
@@ -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)
index a7341f61c01001fd3177db281a25a7b089960216..a26fd83827efd16366aab1d8cf9d67f77354f085 100644 (file)
@@ -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
index cfc7ad38d1a96c5e8403e011bf87b6af708e907b..279ce06541680069741a7426a4c73b89efbb1dd1 100644 (file)
@@ -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);
index 7ad3af9ecbfe2f0a2b23e16c19b95b010fd7af19..6497b2c2482d76883472166f37fb831c7522a14e 100644 (file)
@@ -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 &);
 
index 11429288ca314b4ddca41b8f287188686a6dc171..333463e3bcd336ad4acb8789b59d29171026f5fe 100644 (file)
@@ -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
index 4003ccdf495f3f4a18c8b3f9c3063b49b25f7209..d9c28a1010dca5bbba84c0654dd79fa3c836cfee 100644 (file)
@@ -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
index ffc1846c89508e2195644af31f564ff368c92e2c..1f8a278c482d4369c5cda1bc6495d5030739eee0 100644 (file)
@@ -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;