From 56e0c9ff0788fbd462b25b087417b15eaaa762d7 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Fri, 30 Jul 2021 08:22:22 -0400 Subject: private-lib: fix double symlink --- src/fldd/main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/fldd/main.c b/src/fldd/main.c index 9d91557c1..b71145793 100644 --- a/src/fldd/main.c +++ b/src/fldd/main.c @@ -261,12 +261,21 @@ static void walk_directory(const char *dirname) { // check directory // entry->d_type field is supported in glibc since version 2.19 (Feb 2014) - // we'll use stat to check for directories + // we'll use stat to check for directories using the real path + // (sometimes the path is a double symlink to a real file and stat would fail) + char *rpath = realpath(path, NULL); + if (!rpath) { + free(path); + continue; + } + free(path); + struct stat s; - if (stat(path, &s) == -1) + if (stat(rpath, &s) == -1) errExit("stat"); if (S_ISDIR(s.st_mode)) - walk_directory(path); + walk_directory(rpath); + free(rpath); } closedir(dir); } -- cgit v1.2.3-54-g00ecf