Commit b43da45b authored by Timo Teräs's avatar Timo Teräs

gunzip: fix false end-of-file condition in rare circumstances

It turns out inflate() can output zero bytes, even if it consumed
data. This had the unfortunate side effect of returning zero bytes
(end-of-file) condition before calling the boundary callbacks. This
fixes the logic to not return zero reads on gzip boundary.

In practice this fixes the seldom seen issues of apk reporting
bad signature (when it was correct).
parent c4c8aa5b
......@@ -104,7 +104,7 @@ static ssize_t gzi_read(struct apk_istream *is, void *ptr, size_t size)
inflateEnd(&gis->zs);
if (inflateInit2(&gis->zs, 15+32) != Z_OK)
return -ENOMEM;
if (gis->cb) goto ret;
if (gis->cb && gis->zs.avail_out != size) goto ret;
break;
case Z_OK:
break;
......
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