From 36551cca8349349718fc17e475bc2fbbbc7260f5 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 16 Oct 2017 11:30:22 -0500 Subject: [PATCH] libpkgconf: path: relocate the path before doing dedup checks (closes #151) --- libpkgconf/path.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libpkgconf/path.c b/libpkgconf/path.c index d242759..b7214fc 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -80,12 +80,15 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter) pkgconf_path_t *node; char path[PKGCONF_BUFSIZE]; + pkgconf_strlcpy(path, text, sizeof path); + pkgconf_path_relocate(path, sizeof path); + #ifdef PKGCONF_CACHE_INODES struct stat st; if (filter) { - if (lstat(text, &st) == -1) + if (lstat(path, &st) == -1) return; if (S_ISLNK(st.st_mode)) { @@ -93,23 +96,20 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter) ssize_t len; 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) && stat(linkdest, &st) == -1) return; } - if (path_list_contains_entry(text, dirlist, &st)) + if (path_list_contains_entry(path, dirlist, &st)) return; } #else - if (filter && path_list_contains_entry(text, dirlist)) + if (filter && path_list_contains_entry(path, dirlist)) return; #endif - pkgconf_strlcpy(path, text, sizeof path); - pkgconf_path_relocate(path, sizeof path); - node = calloc(sizeof(pkgconf_path_t), 1); node->path = strdup(path);