projects
/
onak.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7f5cb14
)
Fix buffer_getchar to only error if we'd exceed the buffer size
author
Jonathan McDowell
<noodles@earth.li>
Mon, 25 Apr 2011 01:33:13 +0000
(18:33 -0700)
committer
Jonathan McDowell
<noodles@earth.li>
Mon, 25 Apr 2011 01:33:13 +0000
(18:33 -0700)
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.
charfuncs.c
patch
|
blob
|
history
diff --git
a/charfuncs.c
b/charfuncs.c
index fea0a99cf0081218b831794b55dc8db599e31176..8448aee1be579956a71b2480850fb534685b15d1 100644
(file)
--- a/
charfuncs.c
+++ b/
charfuncs.c
@@
-25,11
+25,15
@@
int buffer_fetchchar(void *ctx, size_t count, void *c)
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;
- return
(((buf->offset) == (buf->size)) ? 1 : 0)
;
+ return
0
;
}
/**