summaryrefslogtreecommitdiff
path: root/libc/misc/internals/parse_config.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2010-08-19 19:06:26 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2010-08-19 19:08:21 +0200
commit72e1a1ce186c39f07282398e2af9eb0253e60f15 (patch)
treec2bc32542282397cfd66d3c2e84305208d9c207e /libc/misc/internals/parse_config.c
parent39da92a8c926ce73b5b3792bf8c9da3cff6f4d64 (diff)
getserv: fix reading services lines w > 80 chars
e.g. getservbyname() Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/misc/internals/parse_config.c')
-rw-r--r--libc/misc/internals/parse_config.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libc/misc/internals/parse_config.c b/libc/misc/internals/parse_config.c
index 9ddf3ee38..e38025f2b 100644
--- a/libc/misc/internals/parse_config.c
+++ b/libc/misc/internals/parse_config.c
@@ -73,6 +73,10 @@ static off_t bb_get_chunk_with_continuation(parser_t* parsr)
--pos;
else
break;
+ } else if (parsr->allocated) {
+ parsr->line_len += PAGE_SIZE;
+ parsr->data = realloc(parsr->data,
+ parsr->data_len + parsr->line_len);
}
}
return pos;
@@ -109,9 +113,8 @@ static __always_inline parser_t * FAST_FUNC config_open2(const char *filename,
fp = fopen_func(filename, "r");
if (!fp)
return NULL;
- parser = malloc(sizeof(*parser));
+ parser = calloc(1, sizeof(*parser));
if (parser) {
- memset(parser, 0, sizeof(*parser));
parser->fp = fp;
}
return parser;
@@ -179,7 +182,7 @@ int attribute_hidden FAST_FUNC config_read(parser_t *parser, char ***tokens,
again:
if (parser->data == NULL) {
if (parser->line_len == 0)
- parser->line_len = PAGE_SIZE;
+ parser->line_len = 81;
if (parser->data_len == 0)
parser->data_len += 1 + ntokens * sizeof(char *);
parser->data = realloc(parser->data,
@@ -201,7 +204,7 @@ again:
return 0;
line = parser->line;
- /* Skip token in the start of line? */
+ /* Skip multiple token-delimiters in the start of line? */
if (flags & PARSE_TRIM)
line += strspn(line, delims + 1);