From 298fa0ef5ba39445f960ab056c0d102ae8af91c5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 17 Oct 2017 08:58:13 +0300 Subject: Merge with latest original package version (master branch) --- libpkgconf/path.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'libpkgconf/path.c') diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 36855fe..2f4cfbb 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -80,33 +80,36 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter) pkgconf_path_t *node; char path[PKGCONF_ITEM_SIZE]; + 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)) { char linkdest[PKGCONF_ITEM_SIZE]; - ssize_t len = readlink(text, linkdest, sizeof(linkdest)); + ssize_t len; + + memset(linkdest, '\0', 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); -- cgit v1.1