Audit reveals only one of several callers which might set negative length
state were checking for it and setting error flag properly.
Makes more sense for the StoreIOBuffer constructor to do its own
error state detection with information than to offload on callers.
{
public:
- StoreIOBuffer():length(0), offset (0), data (NULL){flags.error = 0;}
+ StoreIOBuffer():length(0), offset (0), data (NULL) {flags.error = 0;}
StoreIOBuffer(size_t aLength, int64_t anOffset, char *someData) :
- length (aLength), offset (anOffset), data (someData)
+ offset (anOffset), data (someData)
{
- flags.error = 0;
+ /* maintain own state: detect size errors now */
+ if (aLength <0) {
+ flags.error = 1;
+ length = 0;
+ }
+ else {
+ flags.error = 0;
+ length = aLength;
+ }
}
/* Create a StoreIOBuffer from a MemBuf and offset */
void
store_client::callback(ssize_t sz, bool error)
{
- StoreIOBuffer result (sz, 0 ,copyInto.data);
+ 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;