From c0df3440a44ac74a09115b536019b8ca6076245f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 21 Aug 2015 15:17:18 +0100 Subject: 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. --- ChangeLog | 3 +++ Src/glob.c | 14 ++++++++++---- 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 + * 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) { -- cgit 1.4.1