summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-10 15:55:36 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-10 15:55:36 +0200
commitab54032f297e9418b0d83970cbe3a414d6ef08c4 (patch)
treecf03e2e5f08dedc70f0a12823d3c52e32ed5ffef /src/fileio.c
parenteebd555733491cb55b9f30fe28772c0fd0ebacf7 (diff)
downloadvim-git-ab54032f297e9418b0d83970cbe3a414d6ef08c4.tar.gz
patch 8.2.0947: readdirex() doesn't handle broken link properlyv8.2.0947
Problem: Readdirex() doesn't handle broken link properly. Solution: Small fixes to readdirex(). (Christian Brabandt, closes #6226, closes #6213)
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 4da3afc54..06a4c51a3 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4544,7 +4544,7 @@ create_readdirex_item(char_u *path, char_u *name)
int ret, link = FALSE;
varnumber_T size;
char_u permbuf[] = "---------";
- char_u *q;
+ char_u *q = NULL;
struct passwd *pw;
struct group *gr;
@@ -4563,6 +4563,9 @@ create_readdirex_item(char_u *path, char_u *name)
{
link = TRUE;
ret = mch_stat(p, &st);
+ if (ret < 0)
+ q = (char_u*)"link";
+
}
vim_free(p);
@@ -4617,7 +4620,7 @@ create_readdirex_item(char_u *path, char_u *name)
goto theend;
if (dict_add_number(item, "time", -1) == FAIL)
goto theend;
- if (dict_add_string(item, "type", (char_u*)"") == FAIL)
+ if (dict_add_string(item, "type", q == NULL ? (char_u*)"" : q) == FAIL)
goto theend;
if (dict_add_string(item, "perm", (char_u*)"") == FAIL)
goto theend;
@@ -4719,6 +4722,11 @@ readdir_core(
ignore = wp[0] == L'.' &&
(wp[1] == NUL ||
(wp[1] == L'.' && wp[2] == NUL));
+ if (ignore)
+ {
+ ok = FindNextFileW(hFind, &wfd);
+ continue;
+ }
# ifdef FEAT_EVAL
if (withattr)
item = (void*)create_readdirex_item(&wfd);
@@ -4787,6 +4795,8 @@ readdir_core(
ignore = p[0] == '.' &&
(p[1] == NUL ||
(p[1] == '.' && p[2] == NUL));
+ if (ignore)
+ continue;
# ifdef FEAT_EVAL
if (withattr)
item = (void*)create_readdirex_item(path, p);