From: Amos Jeffries Date: Wed, 15 Jan 2014 02:11:05 +0000 (+1300) Subject: Cleanup: Fix StoreIOBuffer initialization cases X-Git-Tag: SQUID_3_5_0_1~411 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e7512db67e59a540c1a31ab53c60770daa1d212;p=thirdparty%2Fsquid.git Cleanup: Fix StoreIOBuffer initialization cases 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. --- diff --git a/src/StoreIOBuffer.h b/src/StoreIOBuffer.h index d26bb881fe..eef8a2827f 100644 --- a/src/StoreIOBuffer.h +++ b/src/StoreIOBuffer.h @@ -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 */ diff --git a/src/store_client.cc b/src/store_client.cc index 0e69803756..ea1d014874 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -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());