mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-15 21:59:41 -04:00
BUG/MINOR: tools: make fgets_from_mem() stop at the end of the input
The memchr() used to look for the LF character must consider the end of input, not just the output buffer size. This was found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=71096 No backport is needed.
This commit is contained in:
parent
75944e266e
commit
0982bfd999
1 changed files with 3 additions and 0 deletions
|
|
@ -6681,6 +6681,9 @@ char *fgets_from_mem(char* buf, int size, const char **position, const char *end
|
|||
return NULL;
|
||||
|
||||
size--; /* keep fgets behaviour, reads at most one less than size */
|
||||
if (size > end - *position)
|
||||
size = end - *position;
|
||||
|
||||
new_pos = memchr(*position, '\n', size);
|
||||
if (new_pos) {
|
||||
/* '+1' to grab and copy '\n' at the end of line */
|
||||
|
|
|
|||
Loading…
Reference in a new issue