From fa927fd379f5d38b75cfc3271f094b3466ef09ac Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 19 Jan 2017 10:36:07 -0600 Subject: [PATCH] libpkgconf: path: pkgconf_path_relocate(): implement realpath backend --- libpkgconf/path.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 8523642..e779f75 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -240,7 +240,7 @@ pkgconf_path_free(pkgconf_list_t *dirlist) bool pkgconf_path_relocate(char *buf, size_t buflen) { -#ifdef HAVE_CYGWIN_CONV_PATH +#if defined(HAVE_CYGWIN_CONV_PATH) ssize_t size; char *tmpbuf, *ti; @@ -261,6 +261,21 @@ pkgconf_path_relocate(char *buf, size_t buflen) if (*ti == '\\') *ti = '/'; } +#elif defined(HAVE_REALPATH) + char *tmpbuf; + + if ((tmpbuf = realpath(buf, NULL)) != NULL) + { + size_t tmpbuflen = strlen(tmpbuf); + if (tmpbuflen > buflen) + { + free(tmpbuf); + return false; + } + + pkgconf_strlcpy(buf, tmpbuf, buflen); + free(tmpbuf); + } #else (void) buf; (void) buflen;