From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15074 invoked by alias); 21 Aug 2015 14:10:03 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36264 Received: (qmail 57 invoked from network); 21 Aug 2015 14:10:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f4-f79c56d0000012ee-69-55d731352262 Date: Fri, 21 Aug 2015 15:09:54 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: mkdir builtin and $'\0' Message-id: <20150821150954.79bb3921@pwslap01u.europe.root.pri> In-reply-to: <20150821095721.5790de94@pwslap01u.europe.root.pri> References: <20150818091904.GA5389@chaz.gmail.com> <20150818162040.GC5629@chaz.gmail.com> <20150818173726.02ef5782@pwslap01u.europe.root.pri> <20150821095721.5790de94@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsVy+t/xa7qmhtdDDQ5ulbc42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGTt2L2UqaBeseP7qJlMD4xeeLkYODgkBE4mN2yS6GDmBTDGJ C/fWs3UxcnEICSxllFh86zyUM4NJYvPVp+wQzjZGiT0flzGCtLAIqEr83d3FCmKzCRhKTN00 GywuIqAlsePkSSYQW1hAReJlYwcbyDZeAXuJM99dQcKcAg4SX1tWsULM7GOS6H20DayeX0Bf 4urfT0wQJ9lLzLxyBmwmr4CgxI/J91hAbGag+Zu3NbFC2PISm9e8ZQaxhQTUJW7c3c0+gVFo FpKWWUhaZiFpWcDIvIpRNLU0uaA4KT3XUK84Mbe4NC9dLzk/dxMjJGi/7GBcfMzqEKMAB6MS D++MyGuhQqyJZcWVuYcYJTiYlUR4d8peDxXiTUmsrEotyo8vKs1JLT7EKM3BoiTOO3fX+xAh gfTEktTs1NSC1CKYLBMHp1QDI+Pj6aF7FOa3RU2yLV7qERHBZ7rVf62Za+V8mQ+6vrs/a3i5 hPie7tRf687GNrfHcq7qr4eMHqsLPa2z/ioJH7PyPF182XxJ2U4R3ZN/T1nyxMSL9bfUd1eX XNP7FJWWJLz64AvtN7eXnTt05c6ZzY7MlyZ4JWl/np/bqD/n4YXXguqNsavFlViKMxINtZiL ihMBosMssVYCAAA= On Fri, 21 Aug 2015 09:57:21 +0100 Peter Stephenson 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) {