summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-08-22 21:12:29 +0000
committerrillig <rillig@NetBSD.org>2020-08-22 21:12:29 +0000
commit7c577f49cf0822dff76c7e8cd2e94e8fbd757fd9 (patch)
tree4ae7165a789f73237e92afc8a14a958bbc3c7b61 /usr.bin/make/parse.c
parenta20c3fcd7986fee8017f393c6fafc2e8e82ca591 (diff)
make(1): fix undefined behavior when assigning to variable ""
Using a programming language with built-in array bounds checks would have prevented this bug, and many others as well.
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r--usr.bin/make/parse.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 2b1eda4ba65..d16590b74b5 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.258 2020/08/22 17:34:25 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.259 2020/08/22 21:12:29 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.258 2020/08/22 17:34:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.259 2020/08/22 21:12:29 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.258 2020/08/22 17:34:25 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.259 2020/08/22 21:12:29 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1876,7 +1876,7 @@ Parse_DoVar(char *line, GNode *ctxt)
* XXX Rather than counting () and {} we should look for $ and
* then expand the variable.
*/
- for (depth = 0, cp = line + 1; depth > 0 || *cp != '='; cp++) {
+ for (depth = 0, cp = line; depth > 0 || *cp != '='; cp++) {
if (*cp == '(' || *cp == '{') {
depth++;
continue;