aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2003-10-06 17:37:20 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2003-10-06 17:37:20 +0000
commitae43b8065d3b7025408196267f4b5e59cf360dea (patch)
tree24b450a93b3f8f4540bed58688a2b5405e39caa3 /usr.bin
parentf6e01094a4fc1e1cf44c2d1d806b211b9f351086 (diff)
downloadsrc-ae43b8065d3b7025408196267f4b5e59cf360dea.tar.gz
src-ae43b8065d3b7025408196267f4b5e59cf360dea.zip
Fix a bug in variable parsing code that could cause a segfault.
PR: bin/46203 Submitted by: Stefan Farfeleder <stefan@fafoe.dyndns.org>
Notes
Notes: svn path=/head/; revision=120859
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/var.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index dd39ce6bc9f9..bbc82708ee79 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -843,7 +843,8 @@ VarREError(int err, regex_t *pat, const char *str)
* The (possibly-modified) value of the variable or var_Error if the
* specification is invalid. The length of the specification is
* placed in *lengthPtr (for invalid specifications, this is just
- * 2...?).
+ * 2 to skip the '$' and the following letter, or 1 if '$' was the
+ * last character in the string).
* A Boolean in *freePtr telling whether the returned string should
* be freed by the caller.
*
@@ -892,7 +893,10 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
if (v == (Var *)NULL) {
- *lengthPtr = 2;
+ if (str[1] != '\0')
+ *lengthPtr = 2;
+ else
+ *lengthPtr = 1;
if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) {
/*