Skip to content
Merged
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
9 changes: 5 additions & 4 deletions src/Zip/ZipFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,16 +1249,17 @@ long TestLocalHeader(ZipEntry entry, HeaderTest tests)
// Size can be verified only if it is known in the local header.
// it will always be known in the central header.
if (((localFlags & (int)GeneralBitFlags.Descriptor) == 0) ||
((size > 0) || (compressedSize > 0))) {
((size > 0 || compressedSize > 0) && entry.Size > 0)) {

if (size != entry.Size) {
if ((size != 0)
&& (size != entry.Size)) {
throw new ZipException(
string.Format("Size mismatch between central header({0}) and local header({1})",
entry.Size, size));
}

if (compressedSize != entry.CompressedSize &&
compressedSize != 0xFFFFFFFF && compressedSize != -1) {
if ((compressedSize != 0)
&& (compressedSize != entry.CompressedSize && compressedSize != 0xFFFFFFFF && compressedSize != -1)) {
throw new ZipException(
string.Format("Compressed size mismatch between central header({0}) and local header({1})",
entry.CompressedSize, compressedSize));
Expand Down