summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-10-29 21:20:56 +0000
committerjilles <jilles@FreeBSD.org>2010-10-29 21:20:56 +0000
commit038f244ca5f22b5852085641fac4c4d1cbf5ade4 (patch)
tree0771179a4c9b7713d2ece503847968f527184286
parent34092e2279acaed8823708a37b136bfed09547d2 (diff)
downloadFreeBSD-src-038f244ca5f22b5852085641fac4c4d1cbf5ade4.zip
FreeBSD-src-038f244ca5f22b5852085641fac4c4d1cbf5ade4.tar.gz
sh: Reject function names ending in one of !%*+-=?@}~
These do something else in ksh: name=(...) is an array or compound variable assignment and the others are extended patterns. This is the last patch of the ones tested in the exp run. Exp-run done by: pav (with some other sh(1) changes)
-rw-r--r--bin/sh/parser.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index fa670f1..f4d38ed 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -644,9 +644,13 @@ simplecmd(union node **rpp, union node *redir)
/*
* - Require plain text.
* - Functions with '/' cannot be called.
+ * - Reject name=().
+ * - Reject ksh extended glob patterns.
*/
if (!noexpand(n->narg.text) || quoteflag ||
- strchr(n->narg.text, '/'))
+ strchr(n->narg.text, '/') ||
+ strchr("!%*+-=?@}~",
+ n->narg.text[strlen(n->narg.text) - 1]))
synerror("Bad function name");
rmescapes(n->narg.text);
if (find_builtin(n->narg.text, &special) >= 0 &&
OpenPOWER on IntegriCloud