We were erroring when we retrieved the end of the buffer, and not
if we overflowed past the end. Check if we'd overflow and return
an error only in that case.
struct buffer_ctx *buf = NULL;
buf = (struct buffer_ctx *) ctx;
struct buffer_ctx *buf = NULL;
buf = (struct buffer_ctx *) ctx;
+
+ if (buf->offset + count > buf->size) {
+ return 1;
+ }
memcpy(c, &buf->buffer[buf->offset], count);
buf->offset += count;
memcpy(c, &buf->buffer[buf->offset], count);
buf->offset += count;
- return (((buf->offset) == (buf->size)) ? 1 : 0);