Skip to content

Commit

Permalink
private-lib: fix double symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Jul 30, 2021
1 parent 2eb35d0 commit 56e0c9f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/fldd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 56e0c9f

Please sign in to comment.