summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2001-05-15 13:31:04 +0000
committerMarc Espie <espie@cvs.openbsd.org>2001-05-15 13:31:04 +0000
commitebd2c4a176260ecc3768ec4cc4adebdec9104e68 (patch)
treebfc5656e6c169bcd27432d470642e223ed310f88 /usr.bin
parentb39a3a8e7684fa95d5f249c83d84e90575acec0f (diff)
Don't go beyond end of string.
Handles unterminated variables, and fixes regression test #10
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/var.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 05b8c976b9b..11c3be411ed 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: var.c,v 1.53 2001/05/03 13:41:13 espie Exp $ */
+/* $OpenBSD: var.c,v 1.54 2001/05/15 13:31:03 espie Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
@@ -128,7 +128,7 @@
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
UNUSED
-static char rcsid[] = "$OpenBSD: var.c,v 1.53 2001/05/03 13:41:13 espie Exp $";
+static char rcsid[] = "$OpenBSD: var.c,v 1.54 2001/05/15 13:31:03 espie Exp $";
#endif
#endif /* not lint */
@@ -968,7 +968,10 @@ Var_ParseSkip(str, ctxt, result)
/* Find eventual modifiers in the variable */
tstr = Var_Name_Get(str, &name, ctxt, FALSE, find_pos(endc));
Var_Name_Free(&name);
- length = tstr+1 - start;
+ length = tstr - start;
+ /* Terminated correctly */
+ if (*tstr != '\0')
+ length++;
}
if (result != NULL)
@@ -1070,7 +1073,9 @@ Var_Parse(str, ctxt, err, lengthPtr, freePtr)
/* Find eventual modifiers in the variable */
tstr = Var_Name_Get(str, &name, ctxt, FALSE, find_pos(endc));
- *lengthPtr = tstr+1 - start;
+ *lengthPtr = tstr - start;
+ if (*tstr != '\0')
+ (*lengthPtr)++;
}
idx = quick_lookup(name.s, &name.e, &k);