diff --git a/NEWS b/NEWS index c4396e4..97fc2ef 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ Changes from 1.6.0 to 1.6.1: - Fixed a regression where having an empty PKG_CONFIG_LIBDIR environment variable would not eliminate the default search paths. + - Use POSIX realpath(3) instead of readlink() for deduplicating the + search path. Use _fullpath() on Windows for the same purpose. Changes from 1.5.4 to 1.6.0: ---------------------------- diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 3813ea5..9a3ebab 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -41,6 +41,10 @@ extern "C" { #define PKG_DIR_SEP_S '/' #endif +#ifdef _WIN32 +#define realpath(N,R) _fullpath((R),(N),_MAX_PATH) +#endif + #define PKGCONF_BUFSIZE (65535) typedef enum { diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 02d1c97..6b92458 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -92,14 +92,9 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter) return; if (S_ISLNK(st.st_mode)) { - char linkdest[PKGCONF_ITEM_SIZE]; - ssize_t len; + char *linkdest = realpath(path, NULL); - memset(linkdest, '\0', sizeof linkdest); - len = readlink(path, linkdest, sizeof linkdest); - - if (len != -1 && (size_t)len < sizeof(linkdest) && - stat(linkdest, &st) == -1) + if (linkdest != NULL && stat(linkdest, &st) == -1) return; } if (path_list_contains_entry(path, dirlist, &st))