Fix bug for large files (no test because testing 4 GB files would be

very slow)
This commit is contained in:
alqualos 2016-08-23 17:32:27 +00:00
parent 388919583b
commit 9a0efc9532

View file

@ -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;