xbps_symlink_target: fix bug introduced in b81b9ab.

This commit is contained in:
Juan RP
2016-02-04 09:55:46 +01:00
parent 1394f69de0
commit 91067c0547

View File

@@ -492,24 +492,23 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt)
free(p); free(p);
p = xbps_sanitize_path(buf); p = xbps_sanitize_path(buf);
assert(p); assert(p);
if ((strstr(p, "./")) && (p1 = realpath(p, buf))) { if ((strstr(p, "./")) && (p1 = realpath(p, NULL))) {
if (strcmp(xhp->rootdir, "/") == 0) { if (strcmp(xhp->rootdir, "/") == 0) {
res = p1; res = strdup(p1);
} else { } else {
res = strdup(p1 + strlen(xhp->rootdir)); res = strdup(p1 + strlen(xhp->rootdir));
free(p1);
} }
free(p); free(p1);
} else { } else {
if (strcmp(xhp->rootdir, "/") == 0) { if (strcmp(xhp->rootdir, "/") == 0) {
res = p; res = strdup(p);
} else { } else {
res = strdup(p + strlen(xhp->rootdir)); res = strdup(p + strlen(xhp->rootdir));
free(p);
} }
} }
assert(res); assert(res);
free(lnk); free(lnk);
free(p);
} else { } else {
/* absolute */ /* absolute */
res = lnk; res = lnk;