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
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi> * Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi>
* All rights reserved. * 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 * 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. * 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) ...@@ -29,6 +29,7 @@ static size_t gz_read(void *stream, void *ptr, size_t size)
{ {
struct apk_gzip_istream *gis = struct apk_gzip_istream *gis =
container_of(stream, struct apk_gzip_istream, is); container_of(stream, struct apk_gzip_istream, is);
int restart_count = 0;
if (gis->z_err == Z_DATA_ERROR || gis->z_err == Z_ERRNO) if (gis->z_err == Z_DATA_ERROR || gis->z_err == Z_ERRNO)
return -1; return -1;
...@@ -51,6 +52,15 @@ static size_t gz_read(void *stream, void *ptr, size_t size) ...@@ -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); 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) 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