Mercurial > hg > dhcpcd
changeset 2177:e2e3d1064075 draft
Use a different buffer for reading our embedded config
so we don't lose track of it when dealing with whitespace.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 29 Nov 2013 18:38:38 +0000 |
| parents | 0898283fc09a |
| children | 918287089dff |
| files | if-options.c |
| diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/if-options.c Fri Nov 29 18:38:25 2013 +0000 +++ b/if-options.c Fri Nov 29 18:38:38 2013 +0000 @@ -1416,11 +1416,11 @@ { struct if_options *ifo; FILE *f; - char *line, *option, *p; + char *buf, *line, *option, *p; int skip = 0, have_profile = 0; #ifndef EMBEDDED_CONFIG const char **e; - size_t linel, ol; + size_t buflen, ol; #endif /* Seed our default options */ @@ -1478,24 +1478,25 @@ while (f && (line = get_line(f))) { #else - linel = 80; - line = malloc(linel); - if (line == NULL) { + buflen = 80; + buf = malloc(buflen); + if (buf == NULL) { syslog(LOG_ERR, "%s: %m", __func__); return NULL; } for (e = dhcpcd_embedded_conf; *e; e++) { ol = strlen(*e) + 1; - if (ol > linel) { - free(line); - linel = ol; - line = malloc(linel); - if (line == NULL) { + if (ol > buflen) { + free(buf); + buflen = ol; + buf = malloc(buflen); + if (buf == NULL) { syslog(LOG_ERR, "%s: %m", __func__); return NULL; } } - memcpy(line, *e, ol); + memcpy(buf, *e, ol); + line = buf; #endif option = strsep(&line, " \t"); if (line) @@ -1516,7 +1517,7 @@ if (f) fclose(f); #else - free(line); + free(buf); #endif #ifdef INET dhcp_eopts = ifo->dhcp_override;
