summaryrefslogtreecommitdiff
path: root/libc/misc/internals/parse_config.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2010-11-28 21:09:47 +0100
committerCarmelo Amoroso <carmelo.amoroso@st.com>2010-11-28 21:09:47 +0100
commit57f6cce72c889f2e7b342e87a565a064320a6ee2 (patch)
tree5466406472918d3adb63398f5fb9ea1511a5e73f /libc/misc/internals/parse_config.c
parent4ec89b87bc0eea8d9ca6b50564d12eeb3b1b0119 (diff)
parent5dea871ac73ef4608022c058b50adc946917f9b9 (diff)
Merge commit 'origin/master' into prelink
Conflicts: ldso/include/dl-hash.h Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/misc/internals/parse_config.c')
-rw-r--r--libc/misc/internals/parse_config.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/libc/misc/internals/parse_config.c b/libc/misc/internals/parse_config.c
index 8fa324e10..c17d25553 100644
--- a/libc/misc/internals/parse_config.c
+++ b/libc/misc/internals/parse_config.c
@@ -78,6 +78,14 @@ static off_t bb_get_chunk_with_continuation(parser_t* parsr)
parsr->line_len += PAGE_SIZE;
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;
@@ -186,23 +194,20 @@ again:
parser->line_len = 81;
if (parser->data_len == 0)
parser->data_len += 1 + ntokens * sizeof(char *);
- parser->data = realloc(parser->data,
- parser->data_len + parser->line_len);
+ parser->data = malloc(parser->data_len + parser->line_len);
if (parser->data == NULL)
return 0;
parser->allocated |= 1;
} /* else { assert(parser->data_len > 0); } */
- if (parser->line == NULL)
- parser->line = parser->data + parser->data_len;
- if (*tokens == NULL)
- *tokens = (char **) parser->data;
- memset(*tokens, 0, sizeof(*tokens[0]) * ntokens);
+ parser->line = parser->data + parser->data_len;
/*config_free_data(parser);*/
/* Read one line (handling continuations with backslash) */
len = bb_get_chunk_with_continuation(parser);
if (len == -1)
return 0;
+ *tokens = (char **) parser->data;
+ memset(*tokens, 0, sizeof(*tokens[0]) * ntokens);
line = parser->line;
/* Skip multiple token-delimiters in the start of line? */