From: Roy Marples Date: Wed, 19 Jun 2019 17:59:44 +0000 (+0100) Subject: script: Fix a memory error X-Git-Tag: v8.0.0~27^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b42fad1f058e2ad8bb754de9c4cbf6303f027bb3;p=thirdparty%2Fdhcpcd.git script: Fix a memory error --- diff --git a/src/script.c b/src/script.c index 1952a04f..8297eda6 100644 --- a/src/script.c +++ b/src/script.c @@ -491,7 +491,7 @@ dumplease: nenv++; } if (ctx->script_envlen < nenv) { - env = reallocarray(ctx->script_env, nenv, sizeof(*env)); + env = reallocarray(ctx->script_env, nenv + 1, sizeof(*env)); if (env == NULL) goto eexit; ctx->script_env = env; @@ -500,7 +500,7 @@ dumplease: bufp = buf; envp = ctx->script_env; *envp++ = bufp++; - envp--; /* Avoid setting the last \0 to an invalid pointer */ + endp--; /* Avoid setting the last \0 to an invalid pointer */ for (; bufp < endp; bufp++) { if (*bufp == '\0') *envp++ = bufp + 1;