svn commit: r214534 - head/bin/sh

Jilles Tjoelker jilles at FreeBSD.org
Fri Oct 29 21:20:56 UTC 2010


Author: jilles
Date: Fri Oct 29 21:20:56 2010
New Revision: 214534
URL: http://svn.freebsd.org/changeset/base/214534

Log:
  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)

Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==============================================================================
--- head/bin/sh/parser.c	Fri Oct 29 21:20:14 2010	(r214533)
+++ head/bin/sh/parser.c	Fri Oct 29 21:20:56 2010	(r214534)
@@ -644,9 +644,13 @@ simplecmd(union node **rpp, union node *
 			/*
 			 * - 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 &&


More information about the svn-src-head mailing list