From 6e74339e7d762857579169068b060a4fd3f345c4 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 14 Oct 2010 06:35:07 +0000 Subject: parse_config: discard rest of incomplete line If line is longer then size of given buffer and buffer is not allocated by the config parser itself, then discard rest of line. Signed-off-by: Natanael Copa Signed-off-by: Bernhard Reutner-Fischer --- libc/misc/internals/parse_config.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libc/misc/internals/parse_config.c b/libc/misc/internals/parse_config.c index 6d3b6f4a0..c17d25553 100644 --- a/libc/misc/internals/parse_config.c +++ b/libc/misc/internals/parse_config.c @@ -79,6 +79,13 @@ static off_t bb_get_chunk_with_continuation(parser_t* parsr) parsr->data = realloc(parsr->data, parsr->data_len + parsr->line_len); parsr->line = parsr->data + parsr->data_len; + } else { + /* discard rest of line if not enough space in buffer */ + int c; + do { + c = fgetc(parsr->fp); + } while (c != EOF && c != '\n'); + break; } } return pos; -- cgit v1.2.3