From: Roy Marples Date: Wed, 27 Mar 2019 17:33:03 +0000 (+0000) Subject: script: Parse argument as a string X-Git-Tag: v7.2.0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a497e79aad3fd891c817a15f89c64867a6c20bfd;p=thirdparty%2Fdhcpcd.git script: Parse argument as a string This allows "" to equal /dev/null. --- diff --git a/src/if-options.c b/src/if-options.c index 9ef3bdbb..dee07eb1 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -709,13 +709,23 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, case 'c': ARG_REQUIRED; free(ifo->script); - if (*arg == '\0' || strcmp(arg, "/dev/null") == 0) { + s = parse_string(NULL, 0, arg); + if (s == 0) { ifo->script = NULL; break; } - ifo->script = strdup(arg); - if (ifo->script == NULL) + dl = (size_t)s; + if (s == -1 || (ifo->script = malloc(dl)) == NULL) { logerr(__func__); + return -1; + } + parse_string(ifo->script, dl, arg); + if (ifo->script[0] == '\0' || + strcmp(ifo->script, "/dev/null") == 0) + { + free(ifo->script); + ifo->script = NULL; + } break; case 'd': ifo->options |= DHCPCD_DEBUG;