From b81b9ab379eb43206c63aca9d4166a90f3fd4873 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 2 Feb 2016 11:07:02 +0100 Subject: [PATCH] xbps_symlink_target: fix bb977c7 (v3). --- lib/util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/util.c b/lib/util.c index 1c30f154..a78914dc 100644 --- a/lib/util.c +++ b/lib/util.c @@ -482,24 +482,24 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt) } if (strstr(lnk, "./") || lnk[0] != '/') { - char *p, *p1, *dname, lnkrs[PATH_MAX]; + char *p, *p1, *dname, buf[PATH_MAX]; /* relative */ p = strdup(path); assert(p); dname = dirname(p); assert(dname); - snprintf(lnkrs, sizeof(lnkrs), "%s/%s", dname, lnk); + snprintf(buf, sizeof(buf), "%s/%s", dname, lnk); free(p); - p = xbps_sanitize_path(lnkrs); + p = xbps_sanitize_path(buf); assert(p); - if ((strstr(p, "./")) && (p1 = realpath(p, NULL))) { + if ((strstr(p, "./")) && (p1 = realpath(p, buf))) { if (strcmp(xhp->rootdir, "/") == 0) { - res = strdup(p1); + res = p1; } else { res = strdup(p1 + strlen(xhp->rootdir)); + free(p1); } assert(res); - free(p1); free(p); } if (res == NULL) {