diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-10-17 08:58:13 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-10-17 08:58:13 +0300 |
commit | 298fa0ef5ba39445f960ab056c0d102ae8af91c5 (patch) | |
tree | 0b757fd208848aac0917c9308b04bd761a6ad3c7 /libpkgconf/path.c | |
parent | 05e05a89096c0e78b037567f76b2d1fb1877455d (diff) |
Merge with latest original package version (master branch)
Diffstat (limited to 'libpkgconf/path.c')
-rw-r--r-- | libpkgconf/path.c | 17 |
1 files changed, 10 insertions, 7 deletions
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); |