diff --git a/dir.c b/dir.c index 5985288ecd..086242d80a 100644 --- a/dir.c +++ b/dir.c @@ -788,8 +788,10 @@ static int add_excludes(const char *fname, const char *base, int baselen, fd = open(fname, O_RDONLY); if (fd < 0) warn_on_fopen_errors(fname); - if (S_ISLNK(st.st_mode)) - fstat(fd, &st); + if (S_ISLNK(st.st_mode) && fstat(fd, &st) < 0) { + warn_on_fopen_errors(fname); + fd = -1; + } } } else { fd = open(fname, O_RDONLY);