Skip to content

Commit

Permalink
If PKG_CONFIG_PATH element is a sym link, use the link destination
Browse files Browse the repository at this point in the history
instead of the link for inode caching checks.

See issue 112 & issue 110 (https://github.com/pkgconf/pkgconf/issues)
  • Loading branch information
John Hein committed Jan 26, 2017
1 parent 4cb900d commit 5177d97
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions libpkgconf/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,22 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter)
#ifdef PKGCONF_CACHE_INODES
struct stat st;

if (filter && stat(text, &st) == -1)
return;
if (filter)
{
if (lstat(text, &st) == -1)
return;
if (S_ISLNK(st.st_mode))
{
char linkdest[PKGCONF_BUFSIZE];
ssize_t len = readlink(text, linkdest, sizeof(linkdest));

if (filter && path_list_contains_entry(text, dirlist, &st))
return;
if (len != -1 && (size_t)len < sizeof(linkdest) &&
stat(linkdest, &st) == -1)
return;
}
if (path_list_contains_entry(text, dirlist, &st))
return;
}
#else
if (filter && path_list_contains_entry(text, dirlist))
return;
Expand Down

0 comments on commit 5177d97

Please sign in to comment.