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): fix off-by-one error in :C modifier
details: https://anonhg.NetBSD.org/src/rev/1b9b07a64e61
branches: trunk
changeset: 1012017:1b9b07a64e61
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 19 19:27:08 2020 +0000
description:
make(1): fix off-by-one error in :C modifier
Previously this off-by-one error had invoked undefined behavior.
Until today there was no corresponding unit test though.
diffstat:
usr.bin/make/unit-tests/modmisc.exp | 8 ++++++++
usr.bin/make/var.c | 8 ++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diffs (60 lines):
diff -r 11b95b1149f1 -r 1b9b07a64e61 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp Sun Jul 19 18:35:53 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp Sun Jul 19 19:27:08 2020 +0000
@@ -52,6 +52,10 @@
mod-loop-dollar:$$5$$:
mod-loop-dollar:$$${word}$$:
mod-C-limits:00-ok:1 2323 45456
+make: No subexpression \1
+make: No subexpression \1
+make: No subexpression \1
+make: No subexpression \1
mod-C-limits:11-missing:1 6
mod-C-limits:11-ok:1 22 446
make: No subexpression \2
@@ -59,6 +63,10 @@
make: No subexpression \2
make: No subexpression \2
mod-C-limits:22-missing:1 6
+make: No subexpression \2
+make: No subexpression \2
+make: No subexpression \2
+make: No subexpression \2
mod-C-limits:22-missing:1 6
mod-C-limits:22-ok:1 33 556
exit status 0
diff -r 11b95b1149f1 -r 1b9b07a64e61 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Jul 19 18:35:53 2020 +0000
+++ b/usr.bin/make/var.c Sun Jul 19 19:27:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $ */
+/* $NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1578,7 +1578,7 @@
rp++;
}
- if (n > pat->nsub) {
+ if (n >= pat->nsub) {
Error("No subexpression %s", &errstr[0]);
subbuf = "";
sublen = 0;
Home |
Main Index |
Thread Index |
Old Index