Skip to content

Commit 17c3ed3

Browse files
committed
More Zip64 fixes.
1 parent ab815da commit 17c3ed3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Zip/ZipEntry.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ public bool LocalHeaderRequiresZip64
646646

647647
// TODO: A better estimation of the true limit based on compression overhead should be used
648648
// to determine when an entry should use Zip64.
649-
result = ((this.size >= uint.MaxValue) || (trueCompressedSize >= uint.MaxValue)) &&
649+
result =
650+
((this.size >= uint.MaxValue) || (trueCompressedSize >= uint.MaxValue) || (this.offset >= uint.MaxValue)) &&
650651
((versionToExtract == 0) || (versionToExtract >= ZipConstants.VersionZip64));
651652
}
652653

@@ -660,7 +661,7 @@ public bool LocalHeaderRequiresZip64
660661
public bool CentralHeaderRequiresZip64
661662
{
662663
get {
663-
return LocalHeaderRequiresZip64 || (offset >= 0xffffffff);
664+
return LocalHeaderRequiresZip64;
664665
}
665666
}
666667

@@ -869,6 +870,10 @@ internal void ProcessExtraData(bool localHeader)
869870
if ( localHeader || (compressedSize == uint.MaxValue) ) {
870871
compressedSize = (ulong)extraData.ReadLong();
871872
}
873+
874+
if ( !localHeader && (offset == -1) ) {
875+
offset = extraData.ReadLong();
876+
}
872877
}
873878
else {
874879
if (

src/Zip/ZipFile.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,9 @@ void ReadEntries()
29102910
entry.CompressedSize = csize & 0xffffffffL;
29112911
entry.Flags = bitFlags;
29122912
entry.DosTime = (uint)dostime;
2913+
entry.ZipFileIndex = (long)i;
2914+
entry.Offset = offset;
2915+
entry.ExternalFileAttributes = (int)externalAttributes;
29132916

29142917
if ((bitFlags & 8) == 0) {
29152918
entry.CryptoCheckValue = (byte)(crc >> 24);
@@ -2931,10 +2934,6 @@ void ReadEntries()
29312934
entry.Comment = ZipConstants.ConvertToStringExt(bitFlags, buffer, commentLen);
29322935
}
29332936

2934-
entry.ZipFileIndex = (long)i;
2935-
entry.Offset = offset;
2936-
entry.ExternalFileAttributes = (int)externalAttributes;
2937-
29382937
entries_[i] = entry;
29392938
}
29402939
}

0 commit comments

Comments
 (0)