summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Gustafsson <fredrigu@axis.com>2019-11-19 12:07:44 +0100
committerTimo Teräs <timo.teras@iki.fi>2019-11-22 14:41:55 +0200
commitcfa8b736f897b9bf8906dd38538f6058a5ad2ba6 (patch)
tree0594e2596920aca8908d767c2f48709a803b2857
parent7f80a936b21a33f447beccf666038d083aba04ba (diff)
downloadapk-tools-cfa8b736f897b9bf8906dd38538f6058a5ad2ba6.tar.gz
apk-tools-cfa8b736f897b9bf8906dd38538f6058a5ad2ba6.tar.bz2
apk-tools-cfa8b736f897b9bf8906dd38538f6058a5ad2ba6.tar.xz
apk-tools-cfa8b736f897b9bf8906dd38538f6058a5ad2ba6.zip
Don't unpack files to system root
When unpacking a file that is in root, it got a temporary file name /.apk... however if the --root option was used it should have the name root/.apk... otherwise unpacking will fail if the user does not have write access to /. Signed-off-by: Fredrik Gustafsson <fredrigu@axis.com>
-rw-r--r--src/database.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/database.c b/src/database.c
index 4e41f21..c699444 100644
--- a/src/database.c
+++ b/src/database.c
@@ -2391,7 +2391,11 @@ static const char *format_tmpname(struct apk_package *pkg, struct apk_db_file *f
EVP_MD_CTX_free(mdctx);
apk_blob_push_blob(&b, APK_BLOB_PTR_LEN(f->diri->dir->name, f->diri->dir->namelen));
- apk_blob_push_blob(&b, APK_BLOB_STR("/.apk."));
+ if (f->diri->dir->namelen > 0) {
+ apk_blob_push_blob(&b, APK_BLOB_STR("/.apk."));
+ } else {
+ apk_blob_push_blob(&b, APK_BLOB_STR(".apk."));
+ }
apk_blob_push_hexdump(&b, APK_BLOB_PTR_LEN((char *)md, 24));
apk_blob_push_blob(&b, APK_BLOB_PTR_LEN("", 1));