summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorEric Andersen2000-07-09 02:38:01 +0000
committerEric Andersen2000-07-09 02:38:01 +0000
commit161cf93404784ba22e689fab487f38469ae34b98 (patch)
treecb8487f8fa2c96a8bd977b554a0c26568286e254 /utility.c
parentf12724c21ab0d3f24a087444762ed2220d35259c (diff)
downloadbusybox-161cf93404784ba22e689fab487f38469ae34b98.zip
busybox-161cf93404784ba22e689fab487f38469ae34b98.tar.gz
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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/utility.c b/utility.c
index 3dedc2c..a15ae68 100644
--- a/utility.c
+++ b/utility.c
@@ -1616,7 +1616,7 @@ extern char *get_line_from_file(FILE *file)
if (ch == EOF)
break;
/* grow the line buffer as necessary */
- if (idx > linebufsz-1)
+ if (idx > linebufsz-2)
linebuf = realloc(linebuf, linebufsz += GROWBY);
linebuf[idx++] = (char)ch;
if ((char)ch == '\n')