Module Name: src
Committed By: rillig
Date: Sat Jul 6 10:36:23 UTC 2024
Modified Files:
src/usr.bin/make: str.c
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk
Log Message:
make: error out on a matching malformed matching pattern '[['
To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/str.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-edge.exp
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/varmod-edge.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.103 src/usr.bin/make/str.c:1.104
--- src/usr.bin/make/str.c:1.103 Sun Apr 14 15:21:20 2024
+++ src/usr.bin/make/str.c Sat Jul 6 10:36:23 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.103 2024/04/14 15:21:20 rillig Exp $ */
+/* $NetBSD: str.c,v 1.104 2024/07/06 10:36:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
#include "make.h"
/* "@(#)str.c 5.8 (Berkeley) 6/1/90" */
-MAKE_RCSID("$NetBSD: str.c,v 1.103 2024/04/14 15:21:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.104 2024/07/06 10:36:23 rillig Exp $");
static HashTable interned_strings;
@@ -356,8 +356,10 @@ match_fixed_length:
goto no_match;
while (*pat != ']' && *pat != '\0')
pat++;
- if (*pat == '\0')
+ if (*pat == '\0') {
+ res.error = "Unfinished character list";
pat--;
+ }
continue;
}
Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.24 src/usr.bin/make/unit-tests/varmod-edge.exp:1.25
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.24 Sat Jul 6 10:14:35 2024
+++ src/usr.bin/make/unit-tests/varmod-edge.exp Sat Jul 6 10:36:23 2024
@@ -1,4 +1,5 @@
make: "varmod-edge.mk" line 60: while evaluating variable "MOD" with value "${INP:M${:U*)}}": while evaluating variable "INP" with value "(parentheses)": while evaluating "${:U*)" with value "*)": Unclosed expression, expecting '}' for modifier "U*)"
+make: "varmod-edge.mk" line 88: warning: while evaluating variable "MOD" with value "${INP:M${:U[[}}": while evaluating variable "INP" with value "[ [[ [[[": Unfinished character list in pattern '[[' of modifier ':M'
make: "varmod-edge.mk" line 178: while evaluating variable "MOD" with value "${INP:a\=b}": while evaluating variable "INP" with value "file.c file...": Unfinished modifier ('=' missing)
make: "varmod-edge.mk" line 194: while evaluating variable "MOD" with value "${INP::::}": while evaluating variable "INP" with value "value": Unknown modifier ":"
make: "varmod-edge.mk" line 194: while evaluating variable "MOD" with value "${INP::::}": while evaluating variable "INP" with value "": Unknown modifier ":"
Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.26 src/usr.bin/make/unit-tests/varmod-edge.mk:1.27
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.26 Sat Jul 6 10:14:35 2024
+++ src/usr.bin/make/unit-tests/varmod-edge.mk Sat Jul 6 10:36:23 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.26 2024/07/06 10:14:35 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.27 2024/07/06 10:36:23 rillig Exp $
#
# Tests for edge cases in variable modifiers.
#
@@ -77,14 +77,14 @@ EXP= [
# The pattern in the nested variable has an unclosed character class.
# No error is reported though, and the pattern is closed implicitly.
#
-# XXX: It is unexpected that no error is reported.
-# See str.c, function Str_Match.
+# Before str.c 1.104 from 2024-07-06, no error was reported.
#
# Before 2019-12-02, this test case triggered an out-of-bounds read
# in Str_Match.
INP= [ [[ [[[
MOD= ${INP:M${:U[[}}
EXP= [
+# expect+1: warning: while evaluating variable "MOD" with value "${INP:M${:U[[}}": while evaluating variable "INP" with value "[ [[ [[[": Unfinished character list in pattern '[[' of modifier ':M'
.if ${MOD} != ${EXP}
. warning expected "${EXP}", got "${MOD}"
.endif