Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): document undefined behavior in Parse_I...
details: https://anonhg.NetBSD.org/src/rev/59e3b70b52d2
branches: trunk
changeset: 945646:59e3b70b52d2
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Nov 02 22:44:29 2020 +0000
description:
make(1): document undefined behavior in Parse_IsVar
Sigh. If only C could be compiled in strict mode that detects these
out-of-bounds memory accesses.
diffstat:
usr.bin/make/parse.c | 6 ++++--
usr.bin/make/unit-tests/varname.exp | 6 +++---
usr.bin/make/unit-tests/varname.mk | 6 +++++-
3 files changed, 12 insertions(+), 6 deletions(-)
diffs (70 lines):
diff -r f69cd453ad18 -r 59e3b70b52d2 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Mon Nov 02 22:29:48 2020 +0000
+++ b/usr.bin/make/parse.c Mon Nov 02 22:44:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.420 2020/11/01 00:24:57 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.421 2020/11/02 22:44:29 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.420 2020/11/01 00:24:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.421 2020/11/02 22:44:29 rillig Exp $");
/* types and constants */
@@ -1850,6 +1850,8 @@
#endif
/* Scan for one of the assignment operators outside a variable expansion */
+ /* FIXME: undefined behavior. In unit-tests/varname.mk:try1, at the end
+ * of the loop, p already points to the next line. */
while ((ch = *p++) != 0) {
if (ch == '(' || ch == '{') {
level++;
diff -r f69cd453ad18 -r 59e3b70b52d2 usr.bin/make/unit-tests/varname.exp
--- a/usr.bin/make/unit-tests/varname.exp Mon Nov 02 22:29:48 2020 +0000
+++ b/usr.bin/make/unit-tests/varname.exp Mon Nov 02 22:44:29 2020 +0000
@@ -9,16 +9,16 @@
Result of ${:UVAR(((} is "VAR(((" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
Global:.ALLTARGETS = VAR(((=)
No closing parenthesis in archive specification
-make: "varname.mk" line 26: Error in archive specification: "VAR"
+make: "varname.mk" line 29: Error in archive specification: "VAR"
Var_Parse: ${:UVAR\(\(\(}= try2 with VARE_UNDEFERR|VARE_WANTRES
Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
Result of ${:UVAR\(\(\(} is "VAR\(\(\(" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
Global:.ALLTARGETS = VAR(((=) VAR\(\(\(=
-make: "varname.mk" line 27: Need an operator
+make: "varname.mk" line 30: Need an operator
Var_Parse: ${:UVAR\(\(\(}= try3 with VARE_UNDEFERR|VARE_WANTRES
Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
Result of ${:UVAR\(\(\(} is "VAR\(\(\(" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
-make: "varname.mk" line 28: Need an operator
+make: "varname.mk" line 31: Need an operator
Global:.MAKEFLAGS = -r -k -d v -d
Global:.MAKEFLAGS = -r -k -d v -d 0
make: Fatal errors encountered -- cannot continue
diff -r f69cd453ad18 -r 59e3b70b52d2 usr.bin/make/unit-tests/varname.mk
--- a/usr.bin/make/unit-tests/varname.mk Mon Nov 02 22:29:48 2020 +0000
+++ b/usr.bin/make/unit-tests/varname.mk Mon Nov 02 22:44:29 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varname.mk,v 1.6 2020/11/02 22:29:48 rillig Exp $
+# $NetBSD: varname.mk,v 1.7 2020/11/02 22:44:29 rillig Exp $
#
# Tests for special variables, such as .MAKE or .PARSEDIR.
# And for variable names in general.
@@ -23,6 +23,10 @@
# In the above test, the variable name is constructed indirectly. Neither
# of the following expressions produces the intended effect.
+#
+# This is not a variable assignment since the parentheses and braces are not
+# balanced. At the end of the line, there are still 3 levels open, which
+# means the variable name is not finished.
${:UVAR(((}= try1
${:UVAR\(\(\(}= try2
${:UVAR\(\(\(}= try3
Home |
Main Index |
Thread Index |
Old Index