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>
cute-signatures
Fredrik Gustafsson 2019-11-19 12:07:44 +01:00 committed by Timo Teräs
parent 7f80a936b2
commit cfa8b736f8
1 changed files with 5 additions and 1 deletions

View File

@ -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));