xbps-create: improve d6605e1b97
(sanitize destdir to resolve target files in symlinks).
Previously in d6605e1b97
if destdir had trailing '/' the behavior
of detecting target files in symlinks was changed slightly.
This commit is contained in:
parent
d6605e1b97
commit
fa9d3471d9
@ -178,7 +178,7 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf)
|
|||||||
{
|
{
|
||||||
struct xentry *xe = NULL;
|
struct xentry *xe = NULL;
|
||||||
const char *filep = NULL;
|
const char *filep = NULL;
|
||||||
char *buf, *p, *dname;
|
char *buf, *p, *p2, *dname;
|
||||||
ssize_t r;
|
ssize_t r;
|
||||||
|
|
||||||
(void)ftwbuf;
|
(void)ftwbuf;
|
||||||
@ -237,7 +237,14 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf)
|
|||||||
*/
|
*/
|
||||||
xe->target = strdup(buf);
|
xe->target = strdup(buf);
|
||||||
} else {
|
} else {
|
||||||
xe->target = strdup(p + strlen(destdir) - 1);
|
/*
|
||||||
|
* Sanitize destdir just in case.
|
||||||
|
*/
|
||||||
|
if ((p2 = realpath(destdir, NULL)) == NULL)
|
||||||
|
die("failed to sanitize destdir %s: %s", destdir, strerror(errno));
|
||||||
|
|
||||||
|
xe->target = strdup(p+strlen(p2));
|
||||||
|
free(p2);
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
} else if (strchr(buf, '/') == NULL) {
|
} else if (strchr(buf, '/') == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user