Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zip): 0 in zip64 local sizes using descriptors #750

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,12 +1145,12 @@ private long TestLocalHeader(ZipEntry entry, HeaderTest tests)
if (localFlags.HasAny(GeneralBitFlags.Descriptor))
{
// These may be valid if patched later
if ((size > 0) && (size != entry.Size))
if ((size != 0) && (size != entry.Size))
{
throw new ZipException("Size invalid for descriptor");
}

if ((compressedSize > 0) && (compressedSize != entry.CompressedSize))
if ((compressedSize != 0) && (compressedSize != entry.CompressedSize))
{
throw new ZipException("Compressed size invalid for descriptor");
}
Expand Down
5 changes: 3 additions & 2 deletions src/ICSharpCode.SharpZipLib/Zip/ZipFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ internal static int WriteLocalHeader(Stream stream, ZipEntry entry, out EntryPat
}
else
{
ed.AddLeLong(-1);
ed.AddLeLong(-1);
// If the sizes are stored in the descriptor, the local Zip64 sizes should be 0
ed.AddLeLong(0);
ed.AddLeLong(0);
}
ed.AddNewEntry(1);

Expand Down