mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Fix an out-of-bounds read in fgetline().
Forgot that a zero-length string might have come back from fgets.
Thanks to Hanno Böck for spotting this, with the aid of AFL.
(cherry picked from commit 5815d6a65a
)
This commit is contained in:
parent
c195ff2b4f
commit
cac650b8a5
2
misc.c
2
misc.c
@ -459,7 +459,7 @@ char *fgetline(FILE *fp)
|
||||
int size = 512, len = 0;
|
||||
while (fgets(ret + len, size - len, fp)) {
|
||||
len += strlen(ret + len);
|
||||
if (ret[len-1] == '\n')
|
||||
if (len > 0 && ret[len-1] == '\n')
|
||||
break; /* got a newline, we're done */
|
||||
size = len + 512;
|
||||
ret = sresize(ret, size, char);
|
||||
|
Loading…
Reference in New Issue
Block a user