diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
commit | bfc5d42735c1660263904ec5254cccf539a0a458 (patch) | |
tree | 9bbb81b4a53941427e6f9e65ae55027d9108df8c /Src/compat.c | |
parent | 74561cc51b8867e43cb2937ab2edfb36e2a829bf (diff) | |
parent | 643de931640e01aa246723d2038328ef33737965 (diff) | |
download | zsh-bfc5d42735c1660263904ec5254cccf539a0a458.tar.gz zsh-bfc5d42735c1660263904ec5254cccf539a0a458.zip |
Merge tag 'zsh-5.7.1-test-3' into debian
Test release: 5.7.1-test-3
Diffstat (limited to 'Src/compat.c')
-rw-r--r-- | Src/compat.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Src/compat.c b/Src/compat.c index 7b5c4411c..8ab335aa1 100644 --- a/Src/compat.c +++ b/Src/compat.c @@ -30,8 +30,8 @@ #include "zsh.mdh" #include "compat.pro" -/* Return pointer to first occurence of string t * - * in string s. Return NULL if not present. */ +/* Return pointer to first occurrence of string t * + * in string s. Return NULL if not present. */ /**/ #ifndef HAVE_STRSTR @@ -361,8 +361,18 @@ zgetdir(struct dirsav *d) pino = sbuf.st_ino; pdev = sbuf.st_dev; - /* If they're the same, we've reached the root directory. */ + /* If they're the same, we've reached the root directory... */ if (ino == pino && dev == pdev) { + /* + * ...well, probably. If this was an orphaned . after + * an unmount, or something such, we could be in trouble... + */ + if (stat("/", &sbuf) < 0 || + sbuf.st_ino != ino || + sbuf.st_dev != dev) { + zerr("Failed to get current directory: path invalid"); + return NULL; + } if (!buf[pos]) buf[--pos] = '/'; if (d) { @@ -509,7 +519,7 @@ zgetcwd(void) #endif /* HAVE_GETCWD */ if (!ret) ret = unmeta(pwd); - if (!ret) + if (!ret || *ret == '\0') ret = dupstring("."); return ret; } |