zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: mkdir builtin and $'\0'
Date: Fri, 21 Aug 2015 15:09:54 +0100	[thread overview]
Message-ID: <20150821150954.79bb3921@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20150821095721.5790de94@pwslap01u.europe.root.pri>

On Fri, 21 Aug 2015 09:57:21 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> There are a couple of remaining lchdir() calls in glob.c.  I haven't
> determined whether the arguments are already unmetafied or not.

Evidence seems quite positive that pathbuf in glob.c (and pattern.c) is
supposed to be metafied.

(However, a couple of postdoctoral researchers at an institute in Outer
Mongolia have found new evidence that under some circumstances certain
components of the path may be slightly sensitive to unmetafication in
the infra-red...  I wish this were funny.)

Mikael might to try a bit of globbing with some of his usefully named
directories.

pws

diff --git a/Src/glob.c b/Src/glob.c
index 3af4690..dea1bf5 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) {




  reply	other threads:[~2015-08-21 14:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-18  9:19 Stephane Chazelas
2015-08-18  9:49 ` Peter Stephenson
2015-08-18 11:11   ` Stephane Chazelas
2015-08-18 11:27     ` Peter Stephenson
2015-08-18 12:55       ` Stephane Chazelas
2015-08-18 13:24         ` Peter Stephenson
2015-08-18 14:21           ` Peter Stephenson
2015-08-18 15:07             ` Peter Stephenson
2015-08-18 15:18               ` Peter Stephenson
2015-08-18 15:19               ` Mikael Magnusson
2015-08-19  9:52             ` Peter Stephenson
2015-08-19 13:10               ` Stephane Chazelas
2015-08-18 11:06 ` Peter Stephenson
2015-08-18 16:20 ` Stephane Chazelas
2015-08-18 16:37   ` Peter Stephenson
2015-08-21  6:20     ` Mikael Magnusson
2015-08-21  8:57       ` Peter Stephenson
2015-08-21 14:09         ` Peter Stephenson [this message]
2015-08-20 11:15 Recommend latex surgical gloves ED
2015-08-20 16:42 ` 5.0.9 / 5.1 agani (ws Re: Recommend latex surgical gloves) Peter Stephenson
2015-08-21  3:38   ` Mikael Magnusson
2015-09-04 13:44     ` mkdir builtin and $'\0' Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150821150954.79bb3921@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).