diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-07-09 02:38:01 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-07-09 02:38:01 +0000 |
commit | 161cf93404784ba22e689fab487f38469ae34b98 (patch) | |
tree | cb8487f8fa2c96a8bd977b554a0c26568286e254 /utility.c | |
parent | f12724c21ab0d3f24a087444762ed2220d35259c (diff) | |
download | busybox-w32-161cf93404784ba22e689fab487f38469ae34b98.tar.gz busybox-w32-161cf93404784ba22e689fab487f38469ae34b98.tar.bz2 busybox-w32-161cf93404784ba22e689fab487f38469ae34b98.zip |
Fix a bug in get_line_from_file. If the length of the line is (GROWBY * n) +
GROWBY - 1, then it writes the null character just after the buffer. Yipe.
Fix thanks to Matt Kraai <kraai@alumni.carnegiemellon.edu> Thanks Matt!
-Erik
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1616,7 +1616,7 @@ extern char *get_line_from_file(FILE *file) | |||
1616 | if (ch == EOF) | 1616 | if (ch == EOF) |
1617 | break; | 1617 | break; |
1618 | /* grow the line buffer as necessary */ | 1618 | /* grow the line buffer as necessary */ |
1619 | if (idx > linebufsz-1) | 1619 | if (idx > linebufsz-2) |
1620 | linebuf = realloc(linebuf, linebufsz += GROWBY); | 1620 | linebuf = realloc(linebuf, linebufsz += GROWBY); |
1621 | linebuf[idx++] = (char)ch; | 1621 | linebuf[idx++] = (char)ch; |
1622 | if ((char)ch == '\n') | 1622 | if ((char)ch == '\n') |