summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-16 13:47:26 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-16 13:47:26 +0300
commit0f6d96a4f5a904fd95b96e13715b50befa6a0ee9 (patch)
treee43022707015019f093c14fd1afd2440d6d75ead /src/package.c
parent6715a0ba12af54767ba889de07afe3543b7c1543 (diff)
downloadapk-tools-0f6d96a4f5a904fd95b96e13715b50befa6a0ee9.tar.gz
apk-tools-0f6d96a4f5a904fd95b96e13715b50befa6a0ee9.tar.bz2
apk-tools-0f6d96a4f5a904fd95b96e13715b50befa6a0ee9.tar.xz
apk-tools-0f6d96a4f5a904fd95b96e13715b50befa6a0ee9.zip
gzip: always autoclose the inner stream
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c8
1 files changed, 6 insertions, 2 deletions
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);