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.
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 */
{
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());