]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: Fix StoreIOBuffer initialization cases
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 15 Jan 2014 02:11:05 +0000 (15:11 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 15 Jan 2014 02:11:05 +0000 (15:11 +1300)
When StoreIOBuffer isconstructed with an invalid (negative) size for the
content data mark it as an error immedately and set a valid length of
zero bytes.

Also, remove some unnecessary code in store_client.cc resulting.

  Detected by Coverity Scan. Issue 434132.

src/StoreIOBuffer.h
src/store_client.cc

index d26bb881fe3de7d764eb42bf1f0e790c7a6974bd..eef8a2827f1119f5b9bfb45866ebe30c3ba669e5 100644 (file)
@@ -45,7 +45,12 @@ public:
 
     StoreIOBuffer(size_t aLength, int64_t anOffset, char *someData) :
             length (aLength), offset (anOffset), data (someData) {
-        flags.error = 0;
+        if (aLength < 0) {
+            flags.error = 1;
+            length = 0;
+        } else {
+            flags.error = 0;
+        }
     }
 
     /* Create a StoreIOBuffer from a MemBuf and offset */
index 0e69803756e3090f39296cf41b45bcea80671502..ea1d01487402ad09751a6a49942857231d463fe9 100644 (file)
@@ -134,12 +134,8 @@ store_client::callback(ssize_t sz, bool error)
 {
     StoreIOBuffer result(sz, 0 ,copyInto.data);
 
-    if (sz < 0) {
+    if (error)
         result.flags.error = 1;
-        result.length = 0;
-    } else {
-        result.flags.error = error ? 1 : 0;
-    }
 
     result.offset = cmp_offset;
     assert(_callback.pending());