xbps_symlink_target: fix bb977c7 (v3).
This commit is contained in:
parent
377ec33ecf
commit
b81b9ab379
12
lib/util.c
12
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] != '/') {
|
if (strstr(lnk, "./") || lnk[0] != '/') {
|
||||||
char *p, *p1, *dname, lnkrs[PATH_MAX];
|
char *p, *p1, *dname, buf[PATH_MAX];
|
||||||
/* relative */
|
/* relative */
|
||||||
p = strdup(path);
|
p = strdup(path);
|
||||||
assert(p);
|
assert(p);
|
||||||
dname = dirname(p);
|
dname = dirname(p);
|
||||||
assert(dname);
|
assert(dname);
|
||||||
snprintf(lnkrs, sizeof(lnkrs), "%s/%s", dname, lnk);
|
snprintf(buf, sizeof(buf), "%s/%s", dname, lnk);
|
||||||
free(p);
|
free(p);
|
||||||
p = xbps_sanitize_path(lnkrs);
|
p = xbps_sanitize_path(buf);
|
||||||
assert(p);
|
assert(p);
|
||||||
if ((strstr(p, "./")) && (p1 = realpath(p, NULL))) {
|
if ((strstr(p, "./")) && (p1 = realpath(p, buf))) {
|
||||||
if (strcmp(xhp->rootdir, "/") == 0) {
|
if (strcmp(xhp->rootdir, "/") == 0) {
|
||||||
res = strdup(p1);
|
res = p1;
|
||||||
} else {
|
} else {
|
||||||
res = strdup(p1 + strlen(xhp->rootdir));
|
res = strdup(p1 + strlen(xhp->rootdir));
|
||||||
|
free(p1);
|
||||||
}
|
}
|
||||||
assert(res);
|
assert(res);
|
||||||
free(p1);
|
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user