Commit 3cbccbaf authored by Timo Teräs's avatar Timo Teräs

gunzip: accept concatenated gzip streams

allow .apk to consist of multiple separate gzip streams which
are just concatenated together.
parent fa47cadb
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment