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): prevent appending to read-only variables
details: https://anonhg.NetBSD.org/src/rev/8c63c71e0bd7
branches: trunk
changeset: 1015687:8c63c71e0bd7
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Oct 30 16:09:56 2020 +0000
description:
make(1): prevent appending to read-only variables
diffstat:
usr.bin/make/unit-tests/varname-dot-shell.exp | 18 +++++++++---------
usr.bin/make/unit-tests/varname-dot-shell.mk | 8 ++++----
usr.bin/make/var.c | 6 ++++--
3 files changed, 17 insertions(+), 15 deletions(-)
diffs (89 lines):
diff -r 754ddb0adacf -r 8c63c71e0bd7 usr.bin/make/unit-tests/varname-dot-shell.exp
--- a/usr.bin/make/unit-tests/varname-dot-shell.exp Fri Oct 30 16:08:44 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-shell.exp Fri Oct 30 16:09:56 2020 +0000
@@ -12,19 +12,19 @@
lhs = "(details omitted)", rhs = "(details omitted)", op = !=
ParseReadLine (19): '.MAKEFLAGS: .SHELL+=appended'
ParseDoDependency(.MAKEFLAGS: .SHELL+=appended)
-Command:.SHELL = (details omitted) appended
-CondParser_Eval: ${.SHELL} != "${ORIG_SHELL} appended"
-Var_Parse: ${.SHELL} != "${ORIG_SHELL} appended" with VARE_UNDEFERR|VARE_WANTRES
-Var_Parse: ${ORIG_SHELL} appended" with VARE_WANTRES
-lhs = "/bin/sh appended", rhs = "/bin/sh appended", op = !=
+Ignoring append to .SHELL since it is read-only
+CondParser_Eval: ${.SHELL} != ${ORIG_SHELL}
+Var_Parse: ${.SHELL} != ${ORIG_SHELL} with VARE_UNDEFERR|VARE_WANTRES
+Var_Parse: ${ORIG_SHELL} with VARE_UNDEFERR|VARE_WANTRES
+lhs = "(details omitted)", rhs = "(details omitted)", op = !=
ParseReadLine (27): '.undef .SHELL'
Global:delete .SHELL
ParseReadLine (28): '.SHELL= newly overwritten'
Global:.SHELL = newly overwritten
-CondParser_Eval: ${.SHELL} != "${ORIG_SHELL} appended"
-Var_Parse: ${.SHELL} != "${ORIG_SHELL} appended" with VARE_UNDEFERR|VARE_WANTRES
-Var_Parse: ${ORIG_SHELL} appended" with VARE_WANTRES
-lhs = "/bin/sh appended", rhs = "/bin/sh appended", op = !=
+CondParser_Eval: ${.SHELL} != ${ORIG_SHELL}
+Var_Parse: ${.SHELL} != ${ORIG_SHELL} with VARE_UNDEFERR|VARE_WANTRES
+Var_Parse: ${ORIG_SHELL} with VARE_UNDEFERR|VARE_WANTRES
+lhs = "(details omitted)", rhs = "(details omitted)", op = !=
ParseReadLine (33): '.MAKEFLAGS: -d0'
ParseDoDependency(.MAKEFLAGS: -d0)
Global:.MAKEFLAGS = -r -k -d cpv -d
diff -r 754ddb0adacf -r 8c63c71e0bd7 usr.bin/make/unit-tests/varname-dot-shell.mk
--- a/usr.bin/make/unit-tests/varname-dot-shell.mk Fri Oct 30 16:08:44 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-shell.mk Fri Oct 30 16:09:56 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-shell.mk,v 1.5 2020/10/30 15:09:13 rillig Exp $
+# $NetBSD: varname-dot-shell.mk,v 1.6 2020/10/30 16:09:56 rillig Exp $
#
# Tests for the special .SHELL variable, which contains the shell used for
# running the commands.
@@ -15,9 +15,9 @@
.endif
# Trying to append to the variable.
-# Until 2020-10-30 this was possible.
+# Since 2020-10-30 this is prevented.
.MAKEFLAGS: .SHELL+=appended
-.if ${.SHELL} != "${ORIG_SHELL} appended"
+.if ${.SHELL} != ${ORIG_SHELL}
. error
.endif
@@ -26,7 +26,7 @@
# but in the command-line context.
.undef .SHELL
.SHELL= newly overwritten
-.if ${.SHELL} != "${ORIG_SHELL} appended"
+.if ${.SHELL} != ${ORIG_SHELL}
. error
.endif
diff -r 754ddb0adacf -r 8c63c71e0bd7 usr.bin/make/var.c
--- a/usr.bin/make/var.c Fri Oct 30 16:08:44 2020 +0000
+++ b/usr.bin/make/var.c Fri Oct 30 16:09:56 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.599 2020/10/30 15:39:17 rillig Exp $ */
+/* $NetBSD: var.c,v 1.600 2020/10/30 16:09:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.599 2020/10/30 15:39:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.600 2020/10/30 16:09:56 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -945,6 +945,8 @@
if (v == NULL) {
Var_Set(name, val, ctxt);
+ } else if (v->flags & VAR_READONLY) {
+ VAR_DEBUG1("Ignoring append to %s since it is read-only\n", name);
} else if (ctxt == VAR_CMDLINE || !(v->flags & VAR_FROM_CMD)) {
Buf_AddByte(&v->val, ' ');
Buf_AddStr(&v->val, val);
Home |
Main Index |
Thread Index |
Old Index