Skip to content

Error in calculating ZipEntry._LengthOfTrailer when false DataDescriptor header found in compressed data #1808

@DannyBoyk

Description

@DannyBoyk

EPPlus usage

Commercial use (I have a commercial license)

Environment

Windows

Epplus version

7.5.2

Spreadsheet application

Excel

Description

When the ExcelPackage (zip) itself is using DataDescriptor headers, but a file in the package happens to contain the DataDescriptor header byte signature (0x08074b50) in the compressed bytes of the file itself, the logic in OfficeOpenXml.Package.Ionic.Zip.ZipEntry::ReadHeader is incorrectly incrementing the _LengthOfTrailer value by 16 (or 24 for Zip64 entries) for every iteration of the while (wantMore) loop. It should instead just be assigning the value of 16 (or 24 for Zip64 entries) to _LengthOfTrailer, not incrementing.

In my case, the wantMore loop was iterated over twice and the _LengthOfTrailer value was set to 32, when it should have been set to 16 for the single DataDescriptor header at the end of the compressed bytes. This caused it to skip the LocalEntry header of the next entry and fail to process the file with a BadReadException.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions