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

Tolerate 0-value (missing) local size headers. #3

Merged
merged 1 commit into from
Mar 2, 2016
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