Skip to content

Update of zip file with DataDescriptor using ZipArchive results in corrupted file #26256

@slakul

Description

@slakul

When a zip archive is created some files can have DataDescriptor after LocalFileHeader and compressed data. It is indicated by the flag ZipArchiveEntry.BitFlagValues.DataDescriptor.

The update method in ZipArchive does not clear DataDescriptor flag and also does not write DataDescriptor after compressed data.

In Windows 10 the archive can be opened and files can be extracted, but when I try to add any file then the system reports that the archive is broken.

Steps to reproduce:

  1. create zip file using ZipArchive (ZipArchiveMode.Create) and stream that cannot Seek (in order to use DataDescriptor)
  2. add at least two not empty files with default compression
  3. save the archive
  4. open the created zip file using ZipArchive (ZipArchiveMode.Update)
  5. modify one file in the archive
  6. save the archive
  7. open the archive in Windows 10 using File Explorer
  8. add a file to the archive (use drag & drop)
  9. Windows reports that the archive is corrupted

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions