summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
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))