summaryrefslogtreecommitdiff
path: root/Src/glob.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-08-21 15:17:18 +0100
committerPeter Stephenson <pws@zsh.org>2015-08-21 15:17:18 +0100
commitc0df3440a44ac74a09115b536019b8ca6076245f (patch)
tree1aadca4e6d4e22ddd81ba3b56d5143209c017053 /Src/glob.c
parent06e1542f5c919bff38cd3b774c4b86fed3a6adb4 (diff)
downloadzsh-c0df3440a44ac74a09115b536019b8ca6076245f.tar.gz
zsh-c0df3440a44ac74a09115b536019b8ca6076245f.zip
36264: glob and pattern variable pathbuf is metafied.
Document this and unmetafy it when passing to system calls, including lchdir() which is a system-level interface.
Diffstat (limited to 'Src/glob.c')
-rw-r--r--Src/glob.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Src/glob.c b/Src/glob.c
index 3af46904d..dea1bf50e 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -102,8 +102,14 @@ int badcshglob;
/**/
int pathpos; /* position in pathbuf (needed by pattern code) */
+/*
+ * pathname buffer (needed by pattern code).
+ * It is currently believed the string in here is stored metafied and is
+ * unmetafied temporarily as needed by system calls.
+ */
+
/**/
-char *pathbuf; /* pathname buffer (needed by pattern code) */
+char *pathbuf;
typedef struct stat *Statptr; /* This makes the Ultrix compiler happy. Go figure. */
@@ -495,7 +501,7 @@ scanner(Complist q, int shortcircuit)
if (l >= PATH_MAX)
return;
- err = lchdir(pathbuf + pathbufcwd, &ds, 0);
+ err = lchdir(unmeta(pathbuf + pathbufcwd), &ds, 0);
if (err == -1)
return;
if (err) {
@@ -517,7 +523,7 @@ scanner(Complist q, int shortcircuit)
else if (!strcmp(str, "..")) {
struct stat sc, sr;
- add = (stat("/", &sr) || stat(pathbuf, &sc) ||
+ add = (stat("/", &sr) || stat(unmeta(pathbuf), &sc) ||
sr.st_ino != sc.st_ino ||
sr.st_dev != sc.st_dev);
}
@@ -564,7 +570,7 @@ scanner(Complist q, int shortcircuit)
DPUTS(pathpos == pathbufcwd,
"BUG: filename longer than PATH_MAX");
- err = lchdir(pathbuf + pathbufcwd, &ds, 0);
+ err = lchdir(unmeta(pathbuf + pathbufcwd), &ds, 0);
if (err == -1)
break;
if (err) {