From 9a0efc95323efaa5d1c78f16c7e638dd2fdbdd07 Mon Sep 17 00:00:00 2001 From: alqualos Date: Tue, 23 Aug 2016 17:32:27 +0000 Subject: [PATCH] Fix bug for large files (no test because testing 4 GB files would be very slow) --- quazip/quazip/unzip.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/quazip/quazip/unzip.c b/quazip/quazip/unzip.c index bca03f8..967c970 100644 --- a/quazip/quazip/unzip.c +++ b/quazip/quazip/unzip.c @@ -1845,38 +1845,30 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) } /* end Z_BZIP2ED */ else { - ZPOS64_T uTotalOutBefore,uTotalOutAfter; + uInt uAvailOutBefore,uAvailOutAfter; const Bytef *bufBefore; - ZPOS64_T uOutThis; + uInt uOutThis; int flush=Z_SYNC_FLUSH; - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + uAvailOutBefore = pfile_in_zip_read_info->stream.avail_out; bufBefore = pfile_in_zip_read_info->stream.next_out; - /* - if ((pfile_in_zip_read_info->rest_read_uncompressed == - pfile_in_zip_read_info->stream.avail_out) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - flush = Z_FINISH; - */ err=inflate(&pfile_in_zip_read_info->stream,flush); if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) err = Z_DATA_ERROR; - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - uOutThis = uTotalOutAfter-uTotalOutBefore; + uAvailOutAfter = pfile_in_zip_read_info->stream.avail_out; + uOutThis = uAvailOutBefore - uAvailOutAfter; pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; - pfile_in_zip_read_info->crc32 = - crc32(pfile_in_zip_read_info->crc32,bufBefore, - (uInt)(uOutThis)); + pfile_in_zip_read_info->crc32 + = crc32(pfile_in_zip_read_info->crc32,bufBefore, uOutThis); - pfile_in_zip_read_info->rest_read_uncompressed -= - uOutThis; + pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + iRead += uAvailOutBefore - uAvailOutAfter; if (err==Z_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead;