aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-10 13:52:44 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-10 13:53:47 +0300
commit3cbccbaf99fde94477f1a32a7f4dab36d061e2ca (patch)
treef487cfe9142933c0d9b1fc73a274f7d444b34490 /src
parentfa47cadb98c4fd96e315acb3e96bb2487358f593 (diff)
downloadaports-3cbccbaf99fde94477f1a32a7f4dab36d061e2ca.tar.bz2
aports-3cbccbaf99fde94477f1a32a7f4dab36d061e2ca.tar.xz
gunzip: accept concatenated gzip streams
allow .apk to consist of multiple separate gzip streams which are just concatenated together.
Diffstat (limited to 'src')
-rw-r--r--src/gunzip.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gunzip.c b/src/gunzip.c
index 55c9e66051..2c7ffc2f21 100644
--- a/src/gunzip.c
+++ b/src/gunzip.c
@@ -3,7 +3,7 @@
* Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi>
* All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify it
+ * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation. See http://www.gnu.org/ for details.
*/
@@ -29,6 +29,7 @@ static size_t gz_read(void *stream, void *ptr, size_t size)
{
struct apk_gzip_istream *gis =
container_of(stream, struct apk_gzip_istream, is);
+ int restart_count = 0;
if (gis->z_err == Z_DATA_ERROR || gis->z_err == Z_ERRNO)
return -1;
@@ -51,6 +52,15 @@ static size_t gz_read(void *stream, void *ptr, size_t size)
}
gis->z_err = inflate(&gis->zs, Z_NO_FLUSH);
+ if (restart_count == 0 && gis->z_err == Z_STREAM_END) {
+ inflateEnd(&gis->zs);
+ if (inflateInit2(&gis->zs, 15+32) != Z_OK)
+ return -1;
+ gis->z_err = Z_OK;
+ restart_count++;
+ } else {
+ restart_count = 0;
+ }
}
if (gis->z_err != Z_OK && gis->z_err != Z_STREAM_END)