summary refs log tree commit diff
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
parent06e1542f5c919bff38cd3b774c4b86fed3a6adb4 (diff)
downloadzsh-c0df3440a44ac74a09115b536019b8ca6076245f.tar.gz
zsh-c0df3440a44ac74a09115b536019b8ca6076245f.tar.xz
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.
-rw-r--r--ChangeLog3
-rw-r--r--Src/glob.c14
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 66d1d09e1..5c2cdf8f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-08-21  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 36264: Src/glob.c: pathbuf is apparently metafied; document
+	this and unmetafy for system calls.
+
 	* unposted: README, Etc/FAQ.yo: update latest release from 5.0.8
 	to 5.1 in descriptive text.
 
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) {