diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-07-20 15:20:37 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-07-20 15:20:37 +0300 |
commit | be8b59dbe1525a5885bbe3737aa696a01004d633 (patch) | |
tree | 956c39f74aa79b86bebad5b839cd953c73e589fd /src/gunzip.c | |
parent | 89d1abe4e62b2ee5cb4b442ae0552b44ca217182 (diff) | |
download | apk-tools-be8b59dbe1525a5885bbe3737aa696a01004d633.tar.gz apk-tools-be8b59dbe1525a5885bbe3737aa696a01004d633.tar.bz2 apk-tools-be8b59dbe1525a5885bbe3737aa696a01004d633.tar.xz apk-tools-be8b59dbe1525a5885bbe3737aa696a01004d633.zip |
gzip: fix finalization of compressed output
the unflushed data when closing file can be several thousand kiloes,
loop until all is written out.
Diffstat (limited to 'src/gunzip.c')
-rw-r--r-- | src/gunzip.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gunzip.c b/src/gunzip.c index fb0da05..2b30d46 100644 --- a/src/gunzip.c +++ b/src/gunzip.c @@ -177,12 +177,15 @@ static void gzo_close(void *stream) struct apk_gzip_ostream *gos = (struct apk_gzip_ostream *) stream; unsigned char buffer[1024]; size_t have; + int r; - gos->zs.avail_out = sizeof(buffer); - gos->zs.next_out = buffer; - deflate(&gos->zs, Z_FINISH); - have = sizeof(buffer) - gos->zs.avail_out; - gos->output->write(gos->output, buffer, have); + do { + gos->zs.avail_out = sizeof(buffer); + gos->zs.next_out = buffer; + r = deflate(&gos->zs, Z_FINISH); + have = sizeof(buffer) - gos->zs.avail_out; + gos->output->write(gos->output, buffer, have); + } while (r == Z_OK); gos->output->close(gos->output); deflateEnd(&gos->zs); |