aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelipe Morales <hel.sheep@gmail.com>2015-08-30 18:14:26 -0300
committerJustin M. Keyes <justinkz@gmail.com>2015-09-04 19:56:37 -0400
commit77e416b7115fd6bf8f36176f2d0aaa3369167cff (patch)
tree5319742759c0611c8efd6ef4ee0a04a6e072c2f7 /src
parentc51864b826cadfb4c52d597c4ae5897c3ec1341c (diff)
downloadrneovim-77e416b7115fd6bf8f36176f2d0aaa3369167cff.tar.gz
rneovim-77e416b7115fd6bf8f36176f2d0aaa3369167cff.tar.bz2
rneovim-77e416b7115fd6bf8f36176f2d0aaa3369167cff.zip
do_path_expand: Avoid non-readable directories. #3273
Closes https://github.com/neovim/neovim/issues/3164 Closes https://github.com/neovim/neovim/issues/3194 Closes https://github.com/neovim/neovim/issues/3221 Helped-by: @splinterofchaos Helped-by: @oni-link Helped-by: @justinmk
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/fs.c4
-rw-r--r--src/nvim/path.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 3789da3b17..522e49950c 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -421,10 +421,10 @@ bool os_scandir(Directory *dir, const char *path)
FUNC_ATTR_NONNULL_ALL
{
int r = uv_fs_scandir(&fs_loop, &dir->request, path, 0, NULL);
- if (r <= 0) {
+ if (r < 0) {
os_closedir(dir);
}
- return r > 0;
+ return r >= 0;
}
/// Increments the directory pointer.
diff --git a/src/nvim/path.c b/src/nvim/path.c
index f68cb46f33..a3b5bb7490 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -612,8 +612,8 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
*s = NUL;
Directory dir;
- if (os_scandir(&dir, *buf == NUL ? "." : (char *)buf)
- || os_isdir(*buf == NUL ? (char_u *)"." : (char_u *)buf)) {
+ char *dirpath = (*buf == NUL ? "." : (char *)buf);
+ if (os_file_is_readable(dirpath) && os_scandir(&dir, dirpath)) {
// Find all matching entries.
char_u *name;
scandir_next_with_dots(NULL /* initialize */);