Browse Source

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 <natanael.copa@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Natanael Copa 14 years ago
parent
commit
6e74339e7d
1 changed files with 7 additions and 0 deletions
  1. 7 0
      libc/misc/internals/parse_config.c

+ 7 - 0
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;