forked from ariadne/pkgconf
libpkgconf: path: relocate the path before doing dedup checks (closes #151)
parent
95d62545d5
commit
ce30516200
|
@ -79,12 +79,15 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter)
|
||||||
pkgconf_path_t *node;
|
pkgconf_path_t *node;
|
||||||
char path[PKGCONF_BUFSIZE];
|
char path[PKGCONF_BUFSIZE];
|
||||||
|
|
||||||
|
pkgconf_strlcpy(path, text, sizeof path);
|
||||||
|
pkgconf_path_relocate(path, sizeof path);
|
||||||
|
|
||||||
#ifdef PKGCONF_CACHE_INODES
|
#ifdef PKGCONF_CACHE_INODES
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (filter)
|
if (filter)
|
||||||
{
|
{
|
||||||
if (lstat(text, &st) == -1)
|
if (lstat(path, &st) == -1)
|
||||||
return;
|
return;
|
||||||
if (S_ISLNK(st.st_mode))
|
if (S_ISLNK(st.st_mode))
|
||||||
{
|
{
|
||||||
|
@ -92,23 +95,20 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter)
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
memset(linkdest, '\0', sizeof linkdest);
|
memset(linkdest, '\0', sizeof linkdest);
|
||||||
len = readlink(text, linkdest, sizeof linkdest);
|
len = readlink(path, linkdest, sizeof linkdest);
|
||||||
|
|
||||||
if (len != -1 && (size_t)len < sizeof(linkdest) &&
|
if (len != -1 && (size_t)len < sizeof(linkdest) &&
|
||||||
stat(linkdest, &st) == -1)
|
stat(linkdest, &st) == -1)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (path_list_contains_entry(text, dirlist, &st))
|
if (path_list_contains_entry(path, dirlist, &st))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (filter && path_list_contains_entry(text, dirlist))
|
if (filter && path_list_contains_entry(path, dirlist))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pkgconf_strlcpy(path, text, sizeof path);
|
|
||||||
pkgconf_path_relocate(path, sizeof path);
|
|
||||||
|
|
||||||
node = calloc(sizeof(pkgconf_path_t), 1);
|
node = calloc(sizeof(pkgconf_path_t), 1);
|
||||||
node->path = strdup(path);
|
node->path = strdup(path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue