* Fix issue ID #36822. Total was being misused in check

git-svn-id: trunk@49421 -
(cherry picked from commit affefb6ce0)
This commit is contained in:
michael 2021-05-31 20:07:18 +00:00 committed by marcoonthegit
parent 55d25eea07
commit c17dfa0041

View File

@ -88,6 +88,7 @@ type gz_stream = record
transparent : boolean; { true if input file is not a .gz file }
mode : char; { 'w' or 'r' }
startpos : longint; { start of compressed data in file (header skipped) }
total_out : cardinal; { Total read, over blocks }
end;
type gz_streamp = ^gz_stream;
@ -563,7 +564,7 @@ var
{$endif}
begin
filelen := 0;
s := gz_streamp(f);
start := Pbyte(buf); { starting point for crc computation }
@ -643,7 +644,7 @@ begin
filecrc := getLong (s);
filelen := getLong (s);
if (s^.crc <> filecrc) or (s^.stream.total_out <> filelen)
if (s^.crc <> filecrc) or (s^.stream.total_out-s^.total_out <> filelen)
then s^.z_err := Z_DATA_ERROR
else begin
{ Check for concatenated .gz files: }
@ -651,6 +652,7 @@ begin
if (s^.z_err = Z_OK) then begin
total_in := s^.stream.total_in;
total_out := s^.stream.total_out;
s^.total_out:=total_out;
inflateReset (s^.stream);
s^.stream.total_in := total_in;