summaryrefslogtreecommitdiff
path: root/src/manifest.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-01-11 09:56:42 +0200
committerTimo Teräs <timo.teras@iki.fi>2020-01-11 11:32:51 +0200
commitf123d77e0b903b7459296291e04b6558ceb4c287 (patch)
tree75cc6e28f5f3d86d63922762072a3392d2bb81cb /src/manifest.c
parent1de9ef422c087ee8fc302c9d889dd373dc6dde58 (diff)
downloadapk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.gz
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.bz2
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.xz
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.zip
archive: make apk_tar_parse check and close input stream
simplifies other code quite a bit
Diffstat (limited to 'src/manifest.c')
-rw-r--r--src/manifest.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/manifest.c b/src/manifest.c
index 55fc0af..b967143 100644
--- a/src/manifest.c
+++ b/src/manifest.c
@@ -87,20 +87,15 @@ static int read_file_entry(void *ctx, const struct apk_file_info *ae,
static void process_file(struct apk_database *db, const char *match)
{
struct apk_sign_ctx sctx;
- struct apk_istream *is;
struct manifest_file_ctx ctx = {match, &sctx};
+ int r;
apk_sign_ctx_init(&sctx, APK_SIGN_VERIFY, NULL, db->keys_fd);
- is = apk_istream_gunzip_mpart(apk_istream_from_file(AT_FDCWD, match),
- apk_sign_ctx_mpart_cb, &sctx);
-
- if (IS_ERR_OR_NULL(is)) {
- apk_error("%s: %s", match, strerror(errno));
- return;
- }
-
- (void) apk_tar_parse(is, read_file_entry, &ctx, &db->id_cache);
- apk_istream_close(is);
+ r = apk_tar_parse(
+ apk_istream_gunzip_mpart(apk_istream_from_file(AT_FDCWD, match), apk_sign_ctx_mpart_cb, &sctx),
+ read_file_entry, &ctx, &db->id_cache);
+ apk_sign_ctx_free(&sctx);
+ if (r < 0) apk_error("%s: %s", match, apk_error_str(r));
}
static void process_match(struct apk_database *db, const char *match, struct apk_name *name, void *ctx)