From: Roy Marples Date: Tue, 12 May 2020 13:59:48 +0000 (+0000) Subject: Fix an uninitialised memory access X-Git-Tag: v9.1.0~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=134e8be7751d70f79b65a1943d979851a1e49c26;p=thirdparty%2Fdhcpcd.git Fix an uninitialised memory access --- diff --git a/src/if-options.c b/src/if-options.c index 0cbf55ad..e4b8c49f 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -2407,10 +2407,10 @@ read_config(struct dhcpcd_ctx *ctx, logerr("%s: %s", __func__, EMBEDDED_CONFIG); return ifo; } - if (buf[buflen] != '\0') { + if (buf[buflen - 1] != '\0') { if (buflen < sizeof(buf) - 1) bulen++; - buf[buflen] = '\0'; + buf[buflen - 1] = '\0'; } #else buflen = (ssize_t)strlcpy(buf, dhcpcd_embedded_conf, @@ -2489,10 +2489,10 @@ read_config(struct dhcpcd_ctx *ctx, logerr("%s: %s", __func__, ctx->cffile); return ifo; } - if (buf[buflen] != '\0') { + if (buf[buflen - 1] != '\0') { if ((size_t)buflen < sizeof(buf) - 1) buflen++; - buf[buflen] = '\0'; + buf[buflen - 1] = '\0'; } dhcp_filemtime(ctx, ctx->cffile, &ifo->mtime);