45 lines
1.3 KiB
Diff
45 lines
1.3 KiB
Diff
|
From fa9d3471d921e1d49cdddeeab546d61f04bc1cf1 Mon Sep 17 00:00:00 2001
|
||
|
From: Juan RP <xtraeme@gmail.com>
|
||
|
Date: Mon, 27 May 2013 13:03:40 +0200
|
||
|
Subject: [PATCH] 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.
|
||
|
---
|
||
|
bin/xbps-create/main.c | 11 +++++++++--
|
||
|
1 file changed, 9 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c
|
||
|
index 2a2373d..5d0a265 100644
|
||
|
--- bin/xbps-create/main.c
|
||
|
+++ bin/xbps-create/main.c
|
||
|
@@ -178,7 +178,7 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf)
|
||
|
{
|
||
|
struct xentry *xe = NULL;
|
||
|
const char *filep = NULL;
|
||
|
- char *buf, *p, *dname;
|
||
|
+ char *buf, *p, *p2, *dname;
|
||
|
ssize_t r;
|
||
|
|
||
|
(void)ftwbuf;
|
||
|
@@ -237,7 +237,14 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf)
|
||
|
*/
|
||
|
xe->target = strdup(buf);
|
||
|
} 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);
|
||
|
}
|
||
|
} else if (strchr(buf, '/') == NULL) {
|
||
|
--
|
||
|
1.8.3
|
||
|
|