From: Eric Andersen Date: Sun, 9 Jul 2000 02:38:01 +0000 (-0000) Subject: Fix a bug in get_line_from_file. If the length of the line is (GROWBY * n) + X-Git-Tag: 0_46~28 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=161cf93404784ba22e689fab487f38469ae34b98;p=oweals%2Fbusybox.git 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 Thanks Matt! -Erik --- diff --git a/utility.c b/utility.c index 3dedc2c71..a15ae68da 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')