From: Roy Marples Date: Mon, 31 Aug 2015 09:06:37 +0000 (+0000) Subject: Test prefix as well as variable name when setting static variables. X-Git-Tag: v6.9.3~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ac075a97da6eb69770ea10ab3f03823cb7caf80;p=thirdparty%2Fdhcpcd.git Test prefix as well as variable name when setting static variables. Fixes [e0893837e6]. While here, simplify a condition. --- diff --git a/script.c b/script.c index 4f6a6cc1..86fe9556 100644 --- a/script.c +++ b/script.c @@ -131,8 +131,7 @@ make_var(struct dhcpcd_ctx *ctx, const char *prefix, const char *var) char *v; len = strlen(prefix) + strlen(var) + 2; - v = malloc(len); - if (v == NULL) { + if ((v = malloc(len)) == NULL) { logger(ctx, LOG_ERR, "%s: %m", __func__); return NULL; } @@ -158,8 +157,10 @@ append_config(struct dhcpcd_ctx *ctx, char ***env, size_t *len, eq = strchr(config[i], '='); e1 = (size_t)(eq - config[i] + 1); for (j = 0; j < *len; j++) { - if (strncmp(ne[j] + strlen(prefix) + 1, - config[i], e1) == 0) + if (strncmp(ne[j], prefix, strlen(prefix)) == 0 && + ne[j][strlen(prefix)] == '_' && + strncmp(ne[j] + strlen(prefix) + 1, + config[i], e1) == 0) { p = make_var(ctx, prefix, config[i]); if (p == NULL) {