Skip to content

Writing empty files into ZipOutputStream triggers CRC32 error #123

@ghost

Description

Steps to reproduce

  1. Create a 0-byte file on the disk.
  2. Try to zip it using code like this:
FileStream ostream = File.OpenRead(file);
obuffer = new byte[ostream.Length];
ostream.Read(obuffer, 0, obuffer.Length);
zipOutputStream.Write(obuffer, 0, obuffer.Length);

Expected behavior

The file should be added successfully to the zip stream.

Actual behavior

A CRC32 error is thrown ("not a valid index into buffer").

Workaround

Prevent writing into the archive stream the empty file, e.g.

if (obuffer.Length > 0)
    zipOutputStream.Write(obuffer, 0, obuffer.Length);

Version of SharpZipLib

Obtained from (place an x between the brackets for all that apply)

  • Compiled from source
  • Downloaded DLL from GitHub
  • Downloaded DLL from SourceForge
  • Downloaded DLL from _______
  • DLL included as part of
  • Package installed using:
    • NuGet
    • MyGet
    • Chocolatey

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions