mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-10 15:48:06 -05: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.
This commit is contained in:
parent
fa7b23ce90
commit
5815d6a65a
2
misc.c
2
misc.c
@ -460,7 +460,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…
x
Reference in New Issue
Block a user