]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix an uninitialised memory access
authorRoy Marples <roy@marples.name>
Tue, 12 May 2020 13:59:48 +0000 (13:59 +0000)
committerRoy Marples <roy@marples.name>
Tue, 12 May 2020 13:59:48 +0000 (13:59 +0000)
src/if-options.c

index 0cbf55ad7b02c75884f6186d07de66182b80b067..e4b8c49f887715fd840566caee21bdf083cf6f0c 100644 (file)
@@ -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);