OSDN Git Service

parse_config: discard rest of incomplete line
authorNatanael Copa <natanael.copa@gmail.com>
Thu, 14 Oct 2010 06:35:07 +0000 (06:35 +0000)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Thu, 14 Oct 2010 13:00:00 +0000 (15:00 +0200)
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>
libc/misc/internals/parse_config.c

index 6d3b6f4..c17d255 100644 (file)
@@ -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;