about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-09-27 19:57:25 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-09-27 19:57:25 +0000
commit4a34c9628942a3631500e51b57ce4ccb4ac77fb4 (patch)
treeb1c0d6eba97bf68f361093f91e27cb4eddade013 /Src/builtin.c
parent4ba03217caf578fab92202cd853d8de35aa047ed (diff)
downloadzsh-4a34c9628942a3631500e51b57ce4ccb4ac77fb4.tar.gz
zsh-4a34c9628942a3631500e51b57ce4ccb4ac77fb4.tar.xz
zsh-4a34c9628942a3631500e51b57ce4ccb4ac77fb4.zip
25755/25756: Jörg Sommer: improved handling of module arguments
25759: fix dynamic named directory crash, static named directory consistency
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index d274ef9ad..02f843bf8 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3262,9 +3262,19 @@ bin_hash(char *name, char **argv, Options ops, UNUSED(int func))
 		/* The argument is of the form foo=bar, *
 		 * so define an entry for the table.    */
 		if(OPT_ISSET(ops,'d')) {
-		    Nameddir nd = hn = zshcalloc(sizeof *nd);
-		    nd->node.flags = 0;
-		    nd->dir = ztrdup(asg->value);
+		    /* shouldn't return NULL if asg->name is not NULL */
+		    if (*itype_end(asg->name, IUSER, 0)) {
+			zwarnnam(name,
+				 "invalid character in directory name: %s",
+				 asg->name);
+			returnval = 1;
+			argv++;
+			continue;
+		    } else {
+			Nameddir nd = hn = zshcalloc(sizeof *nd);
+			nd->node.flags = 0;
+			nd->dir = ztrdup(asg->value);
+		    }
 		} else {
 		    Cmdnam cn = hn = zshcalloc(sizeof *cn);
 		    cn->node.flags = HASHED;