Browse Source

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

git-svn-id: trunk@49421 -
michael 4 years ago
parent
commit
affefb6ce0
1 changed files with 4 additions and 2 deletions
  1. 4 2
      packages/paszlib/src/gzio.pas

+ 4 - 2
packages/paszlib/src/gzio.pas

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