View Issue Details

IDProjectCategoryView StatusLast Update
0031219FPCPackagespublic2018-04-01 09:33
ReporterAlex VasilievAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionProduct Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0031219: paszlib, unable to extract with "out of range" error
DescriptionFailing to extract from an archive created by Maven/Java8 with "out of range" error. Other archivers have no problems extracting from it. The archive is attached.
Steps To Reproduceprocedure TestUnZipAll(const FileName, OutputPath: String);
var
  UnZipper: TUnZipper;
begin
  UnZipper := TUnZipper.Create;
  try
    UnZipper.FileName := FileName;
    UnZipper.OutputPath := OutputPath;
    UnZipper.Examine;

    UnZipper.UnZipAllFiles;

  finally
    UnZipper.Free;
  end;
end;
Additional InformationThe range error happens on line 173 of packages/paszlib/src/infcodes.pas file:

      {DUMPBITS(t^.bits);}
      b := b shr t^.bits;
      dec(k, t^.bits);

https://github.com/graemeg/freepascal/blob/master/packages/paszlib/src/infcodes.pas

If range error check is compiled out, then "Invalid CRC checksum while unzipping jre.oracle.win64-1.8.0_111a/bin/javafx_font_t2k.dll." is thrown.

Cheers.
TagsNo tags attached.
Fixed in Revision38657
FPCOldBugId
FPCTarget
Attached Files

Relationships

has duplicate 0032773 resolvedMichael Van Canneyt paszlib inflate of file gives crc error 
related to 0026827 resolvedMichael Van Canneyt Buffer error in TDecompressionStream when decompressing some data without deflate header 
related to 0033493 closedMichael Van Canneyt fix-patch for 0026827-bug for packages\paszlib\src\infcodes.pas, fixes "out of range" on decompressing 

Activities

Alex Vasiliev

2017-01-13 03:41

reporter  

troublemaker.zip (247,114 bytes)

Alex Vasiliev

2017-01-13 04:02

reporter   ~0097443

Note that java's JARs are not compressed by default, which makes it slightly rare ZIP archive...

Also, the value for the k is 5 and for the t^.bits is 9 right before the range check failure.

Maxim Ganetsky

2017-01-13 12:51

reporter   ~0097446

Pazlib belongs to FCL. Moving.

Marco van de Voort

2017-12-06 10:08

manager   ~0104506

I did a quick test, and with win64 I didn't get a warning, but the size didn't match, 536906 instead of 538175

Alfred

2017-12-07 09:24

reporter   ~0104554

Did some checks.

In zstream.pp, I increased the buffersize: all errors gone and file contents 100% !!

Line 114: const bufsize=1638400;

Ross

2017-12-09 05:04

reporter   ~0104602

I tried Line 114: const bufsize=1638400; had no effect.
Original file: Size: 526 KB (538,656 bytes)
After extract: Size: 524 KB (537,271 bytes)

Alfred

2017-12-09 09:16

reporter   ~0104603

@Ross
Are you sure that this new setting was used ?
1: Did you rebuild FPC after this change ?
2: Or did you copy the changed zstream.pp from FPC sources into your test directory ?

Marco van de Voort

2017-12-09 13:55

manager   ~0104606

Last edited: 2017-12-09 13:58

View 2 revisions

Since I had to rebuild FPC anyway, I tested this with 32-bit, and the filesize was still wrong, still 536,906.

So I thought maybe it was some optimization setting, so I built paszlib and miniunz without optimization -> still same result.

Max Nazhalov

2017-12-09 17:10

reporter   ~0104611

Last edited: 2017-12-09 17:28

View 3 revisions

This is a consequence of r31953 [bug 0026827]. Patch suggested there is obviously not properly tested.

EDIT: tracing with debugger leads to exactly this fix.
dec(k, t^.bits) later on line ~ 173 of infcodes.pas makes k negative (k=5, t^.bits=9), but k is unsigned by def -- and further processing gets trashed.

After commenting out r31953 change javafx_font_t2k.dll extracts normally, so I suggest to return to bug 0026827.

Michael Van Canneyt

2018-04-01 09:33

administrator   ~0107499

Resolved using patch of bug ID 33493

Issue History

Date Modified Username Field Change
2017-01-13 03:41 Alex Vasiliev New Issue
2017-01-13 03:41 Alex Vasiliev File Added: troublemaker.zip
2017-01-13 04:02 Alex Vasiliev Note Added: 0097443
2017-01-13 12:51 Maxim Ganetsky Note Added: 0097446
2017-01-13 12:52 Maxim Ganetsky Project Packages => FPC
2017-12-06 09:52 Marco van de Voort Relationship added has duplicate 0032773
2017-12-06 10:08 Marco van de Voort Note Added: 0104506
2017-12-07 09:24 Alfred Note Added: 0104554
2017-12-09 05:04 Ross Note Added: 0104602
2017-12-09 09:16 Alfred Note Added: 0104603
2017-12-09 13:55 Marco van de Voort Note Added: 0104606
2017-12-09 13:58 Marco van de Voort Note Edited: 0104606 View Revisions
2017-12-09 17:10 Max Nazhalov Note Added: 0104611
2017-12-09 17:28 Max Nazhalov Note Edited: 0104611 View Revisions
2017-12-09 17:29 Max Nazhalov Note Edited: 0104611 View Revisions
2017-12-09 17:35 Marco van de Voort Relationship added related to 0026827
2018-03-23 22:09 Michael Van Canneyt Relationship added related to 0033493
2018-03-23 22:11 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-03-23 22:11 Michael Van Canneyt Status new => assigned
2018-04-01 09:33 Michael Van Canneyt Fixed in Revision => 38657
2018-04-01 09:33 Michael Van Canneyt Note Added: 0107499
2018-04-01 09:33 Michael Van Canneyt Status assigned => resolved
2018-04-01 09:33 Michael Van Canneyt Fixed in Version => 3.1.1
2018-04-01 09:33 Michael Van Canneyt Resolution open => fixed
2018-04-01 09:33 Michael Van Canneyt Target Version => 3.2.0