arise when shep-cleanup trims an inactive bucket.
Also added debugging messages which helped to verify that zero-copy
is really invoked where it should.
* (c) 2004, Martin Mares <mj@ucw.cz>
*/
* (c) 2004, Martin Mares <mj@ucw.cz>
*/
#include "lib/lib.h"
#include "lib/unaligned.h"
#include "lib/mempool.h"
#include "lib/lib.h"
#include "lib/unaligned.h"
#include "lib/mempool.h"
{
/* Copy if the original buffer is too small.
* If it is write-protected, copy it also if it is uncompressed. */
{
/* Copy if the original buffer is too small.
* If it is write-protected, copy it also if it is uncompressed. */
+ DBG("NO ZC: %d < %d, %d %08x", len, buck_len, body->can_overwrite_buffer, buck_type);
bb_grow(&buf->bb, buck_len);
len = bread(body, buf->bb.ptr, buck_len);
ptr = buf->bb.ptr;
copied = 1;
}
bb_grow(&buf->bb, buck_len);
len = bread(body, buf->bb.ptr, buck_len);
ptr = buf->bb.ptr;
copied = 1;
}
+ else
+ DBG("ZC (%d >= %d, %d %08x)", len, buck_len, body->can_overwrite_buffer, buck_type);
end = ptr + buck_len;
ptr = decode_attributes(ptr, end, o_hdr, 0); // header
if (buck_type == BUCKET_TYPE_V33_LIZARD) // decompression
{
if (ptr + 8 > end)
end = ptr + buck_len;
ptr = decode_attributes(ptr, end, o_hdr, 0); // header
if (buck_type == BUCKET_TYPE_V33_LIZARD) // decompression
{
if (ptr + 8 > end)
+ {
+ if (ptr == end) // truncated bucket
+ goto commit;
+ RET_ERR(EINVAL);
+ }
len = GET_U32(ptr);
ptr += 4;
uns adler = GET_U32(ptr);
len = GET_U32(ptr);
ptr += 4;
uns adler = GET_U32(ptr);
ptr = decode_attributes(ptr, end, o_body, 2); // body
if (ptr != end)
RET_ERR(EINVAL);
ptr = decode_attributes(ptr, end, o_body, 2); // body
if (ptr != end)
RET_ERR(EINVAL);
if (!copied)
bdirect_read_commit_modified(body, ptr);
}
if (!copied)
bdirect_read_commit_modified(body, ptr);
}