summaryrefslogtreecommitdiffstats
path: root/src/gunzip.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-22 19:56:13 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-22 19:56:13 +0300
commit9b77c053e8fd03348ed04ba09ceaaf7ba99ca6f6 (patch)
tree8c10909550b31d026626879bf644ac346f194056 /src/gunzip.c
parent9b63730d848677672aaa4606a28de4fc17da1dcb (diff)
downloadapk-tools-9b77c053e8fd03348ed04ba09ceaaf7ba99ca6f6.tar.bz2
apk-tools-9b77c053e8fd03348ed04ba09ceaaf7ba99ca6f6.tar.xz
pkg: cleanup the signing code
smaller callback and less cases to check. also reintroduce the oneshot digest flag, hopefully correct this time.
Diffstat (limited to 'src/gunzip.c')
-rw-r--r--src/gunzip.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gunzip.c b/src/gunzip.c
index f00d148..e5144a0 100644
--- a/src/gunzip.c
+++ b/src/gunzip.c
@@ -82,10 +82,13 @@ static ssize_t gzi_read(void *stream, void *ptr, size_t size)
switch (r) {
case Z_STREAM_END:
/* Digest the inflated bytes */
+ if ((gis->bs->flags & APK_BSTREAM_EOF) &&
+ gis->zs.avail_in == 0)
+ gis->err = 1;
if (gis->cb != NULL) {
- r = gis->cb(gis->cbctx, APK_MPART_BOUNDARY,
- APK_BLOB_PTR_LEN(gis->cbprev,
- (void *)gis->zs.next_in - gis->cbprev));
+ r = gis->cb(gis->cbctx,
+ gis->err ? APK_MPART_END : APK_MPART_BOUNDARY,
+ APK_BLOB_PTR_LEN(gis->cbprev, (void *) gis->zs.next_in - gis->cbprev));
if (r > 0)
r = -ECANCELED;
if (r != 0) {
@@ -94,6 +97,8 @@ static ssize_t gzi_read(void *stream, void *ptr, size_t size)
}
gis->cbprev = gis->zs.next_in;
}
+ if (gis->err)
+ goto ret;
inflateEnd(&gis->zs);
if (inflateInit2(&gis->zs, 15+32) != Z_OK)
return -ENOMEM;