From 0f6d96a4f5a904fd95b96e13715b50befa6a0ee9 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Thu, 16 Jul 2009 13:47:26 +0300 Subject: gzip: always autoclose the inner stream --- src/package.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/package.c') diff --git a/src/package.c b/src/package.c index 86595c9..c01a5e8 100644 --- a/src/package.c +++ b/src/package.c @@ -430,12 +430,15 @@ static int apk_pkg_gzip_part(void *ctx, EVP_MD_CTX *mdctx, int part) struct apk_package *apk_pkg_read(struct apk_database *db, const char *file) { struct read_info_ctx ctx; + struct apk_file_info fi; struct apk_bstream *bs; struct apk_istream *tar; char realfile[PATH_MAX]; if (realpath(file, realfile) < 0) return NULL; + if (apk_file_get_info(realfile, APK_CHECKSUM_NONE, &fi) < 0) + return NULL; ctx.pkg = apk_pkg_new(); if (ctx.pkg == NULL) @@ -447,14 +450,15 @@ struct apk_package *apk_pkg_read(struct apk_database *db, const char *file) ctx.db = db; ctx.has_install = 0; + ctx.pkg->size = fi.size; - tar = apk_bstream_gunzip_mpart(bs, FALSE, apk_pkg_gzip_part, &ctx); + tar = apk_bstream_gunzip_mpart(bs, apk_pkg_gzip_part, &ctx); if (apk_parse_tar(tar, read_info_entry, &ctx) < 0) { apk_error("File %s is not an APK archive", file); bs->close(bs, NULL); goto err; } - bs->close(bs, &ctx.pkg->size); + tar->close(tar); if (ctx.pkg->name == NULL) { apk_error("File %s is corrupted", file); -- cgit v1.2.3