summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorsjg <sjg@NetBSD.org>2007-10-09 05:55:03 +0000
committersjg <sjg@NetBSD.org>2007-10-09 05:55:03 +0000
commit3a5409e4ebf899cac0ca0ff76064c350fa7d2579 (patch)
tree70e85b82a8c9f435d51e01a3aede5af3f1c528d0 /usr.bin/make
parent662df2e4adeef2c878cd62e334a124dc80cc6e48 (diff)
Fix an off-by-one error in handing mal-formed modifiers.
The issue seems to have been present for some time, only showed up when running unit-tests on SunOS. Make sure we get an error message, but otherwise behave as before.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/unit-tests/test.exp1
-rw-r--r--usr.bin/make/var.c17
2 files changed, 13 insertions, 5 deletions
diff --git a/usr.bin/make/unit-tests/test.exp b/usr.bin/make/unit-tests/test.exp
index 59c85ab0b0b..3433f838042 100644
--- a/usr.bin/make/unit-tests/test.exp
+++ b/usr.bin/make/unit-tests/test.exp
@@ -73,6 +73,7 @@ Expect: Unclosed variable specification for VAR
make: Unclosed variable specification for VAR
VAR:S,V,v,=Thevariable
Expect: Unclosed variable specification for VAR
+make: Unclosed variable specification for VAR
VAR:S,V,v,=Thevariable
Expect: Unclosed substitution for VAR (, missing)
make: Unclosed substitution for VAR (, missing)
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index e8d6e172ed1..9950e5fed77 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.118 2007/10/05 15:27:46 sjg Exp $ */
+/* $NetBSD: var.c,v 1.119 2007/10/09 05:55:03 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.118 2007/10/05 15:27:46 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.119 2007/10/09 05:55:03 sjg 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.118 2007/10/05 15:27:46 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.119 2007/10/09 05:55:03 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2229,6 +2229,10 @@ ApplyModifiers(char *nstr, const char *tstr,
free(freeIt);
if (*tstr == ':')
tstr++;
+ else if (!*tstr && endc) {
+ Error("Unclosed variable specification for %s", v->name);
+ goto out;
+ }
continue;
}
if (DEBUG(VAR)) {
@@ -3492,11 +3496,14 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
nstr = ApplyModifiers(nstr, tstr, startc, endc,
v, ctxt, errnum, &used, freePtr);
tstr += used;
- *lengthPtr = tstr - start + 1;
} else {
- *lengthPtr = tstr - start + 1;
*WR(tstr) = endc;
}
+ if (*tstr) {
+ *lengthPtr = tstr - start + 1;
+ } else {
+ *lengthPtr = tstr - start;
+ }
if (v->flags & VAR_FROM_ENV) {
Boolean destroy = FALSE;