From 134e8be7751d70f79b65a1943d979851a1e49c26 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 12 May 2020 13:59:48 +0000 Subject: [PATCH] Fix an uninitialised memory access --- src/if-options.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); -- 2.47.2