Skip to content

Commit e589b5e

Browse files
authored
fix(zip): 0 in zip64 local sizes using descriptors (#750)
1 parent e3bb2f3 commit e589b5e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,12 +1145,12 @@ private long TestLocalHeader(ZipEntry entry, HeaderTest tests)
11451145
if (localFlags.HasAny(GeneralBitFlags.Descriptor))
11461146
{
11471147
// These may be valid if patched later
1148-
if ((size > 0) && (size != entry.Size))
1148+
if ((size != 0) && (size != entry.Size))
11491149
{
11501150
throw new ZipException("Size invalid for descriptor");
11511151
}
11521152

1153-
if ((compressedSize > 0) && (compressedSize != entry.CompressedSize))
1153+
if ((compressedSize != 0) && (compressedSize != entry.CompressedSize))
11541154
{
11551155
throw new ZipException("Compressed size invalid for descriptor");
11561156
}

src/ICSharpCode.SharpZipLib/Zip/ZipFormat.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ internal static int WriteLocalHeader(Stream stream, ZipEntry entry, out EntryPat
114114
}
115115
else
116116
{
117-
ed.AddLeLong(-1);
118-
ed.AddLeLong(-1);
117+
// If the sizes are stored in the descriptor, the local Zip64 sizes should be 0
118+
ed.AddLeLong(0);
119+
ed.AddLeLong(0);
119120
}
120121
ed.AddNewEntry(1);
121122

0 commit comments

Comments
 (0)