From a497e79aad3fd891c817a15f89c64867a6c20bfd Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 27 Mar 2019 17:33:03 +0000 Subject: [PATCH] script: Parse argument as a string This allows "" to equal /dev/null. --- src/if-options.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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; -- 2.47.2