about summary refs log tree commit diff
path: root/Src
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
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')
-rw-r--r--Src/builtin.c16
-rw-r--r--Src/subst.c8
2 files changed, 17 insertions, 7 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;
diff --git a/Src/subst.c b/Src/subst.c
index caa2ecfda..95369fdf6 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -529,7 +529,7 @@ filesubstr(char **namptr, int assign)
 
     if (*str == Tilde && str[1] != '=' && str[1] != Equals) {
 	Shfunc dirfunc;
-	char *ptr, *tmp, *res;
+	char *ptr, *tmp, *res, *ptr2;
 	int val;
 
 	val = zstrtol(str + 1, &ptr, 10);
@@ -544,14 +544,14 @@ filesubstr(char **namptr, int assign)
 	    return 1;
 	} else if (str[1] == Inbrack &&
 		   (dirfunc = getshfunc("zsh_directory_name")) &&
-		   (ptr = strchr(str+2, Outbrack))) {
+		   (ptr2 = strchr(str+2, Outbrack))) {
 	    char **arr;
-	    untokenize(tmp = dupstrpfx(str+2, ptr - (str+2)));
+	    untokenize(tmp = dupstrpfx(str+2, ptr2 - (str+2)));
 	    remnulargs(tmp);
 	    arr = subst_string_by_func(dirfunc, "n", tmp);
 	    res = arr ? *arr : NULL;
 	    if (res) {
-		*namptr = dyncat(res, ptr+1);
+		*namptr = dyncat(res, ptr2+1);
 		return 1;
 	    }
 	    if (isset(NOMATCH))