Skip to content

Commit

Permalink
Z-1663 Fixed exception extracting an unpatched local header when comp…
Browse files Browse the repository at this point in the history
…ressed size is -1
  • Loading branch information
David Pierson committed May 25, 2010
1 parent af7f243 commit cfc69a6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
18 changes: 18 additions & 0 deletions doc/Changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
Changes for 0.86.0
+ Multi-member gzip files are now supported. Contributed by Geoff Hart.
+ Zero byte files caused ZipOutputStream to create invalid zipfiles. Contributed by Mark Ritchie.
+ ZipFile.CommitUpdate failed on ODT (Open Document) files when updating in memory. Contributed by Dricks.
+ Exceptions occurring within ZipFile.CommitUpdate were being silently discarded.
+ In FastZip, the NameFilter erroneously removed all escapes from regex. Contributed by John Lemberger.
Note: This is a breaking change - if you had detoured this filter bug via doubled-up backslashes,
please halve them - for example change @"\\\\myextract.txt$" to @"\\myextract.txt$", or
change "\\\\\\\\myextract.txt$" to "\\\\myextract.txt$".
+ AES Encryption and Decryption is now supported.
+ TarArchive now has IsStreamOwner property, for use with MemoryStream.
+ Removed exception "Extra data contains Zip64 information but version 2.0 is not high enough" due to rogue zip creators.
+ FastZip.ExtractZip now accepts an Input Stream.
+ Zip input and output streams can now specify buffer sizes.
+ Solved "NTFS Extra data invalid" exception when reading zip files with zero-length NTFS ExtraData entry.
+ Fixed "Size mismatch" exceptions reading zips created by SharpZipLib with an explicit entry CRC and Size.


Changes for 0.85.5
+ Fix for unreferenced ZipFile causing read failure after garbage collection.
+ Fix to ZipInputStream.CloseEntry were skipping could fail for long values.
Expand Down
2 changes: 1 addition & 1 deletion src/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
[assembly: AssemblyCopyright("Copyright 2001-2010 Mike Krueger, John Reilly")]
[assembly: AssemblyTrademark("Copyright 2001-2010 Mike Krueger, John Reilly")]

[assembly: AssemblyVersion("0.86.0.516")]
[assembly: AssemblyVersion("0.86.0.518")]
[assembly: AssemblyInformationalVersionAttribute("0.86.0")]


Expand Down
4 changes: 3 additions & 1 deletion src/Zip/ZipFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
// HISTORY
// 2009-12-22 Z-1649 Added AES support
// 2010-03-02 Z-1650 Fixed updating ODT archives in memory. Exposed exceptions in updating.
// 2010-05-25 Z-1663 Fixed exception when testing local header compressed size of -1

using System;
using System.Collections;
Expand Down Expand Up @@ -1255,7 +1256,8 @@ long TestLocalHeader(ZipEntry entry, HeaderTest tests)
entry.Size, size));
}

if (compressedSize != entry.CompressedSize) {
if (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
10 changes: 7 additions & 3 deletions src/Zip/ZipInputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
// obligated to do so. If you do not wish to do so, delete this
// exception statement from your version.

// HISTORY
// 2010-05-25 Z-1663 Fixed exception when testing local header compressed size of -1

using System;
using System.Text;
using System.IO;

using ICSharpCode.SharpZipLib.Checksums;
Expand Down Expand Up @@ -613,8 +615,10 @@ int BodyRead(byte[] buffer, int offset, int count)
throw new ZipException("Inflater not finished!");
}
inputBuffer.Available = inf.RemainingInput;

if ((flags & 8) == 0 && (inf.TotalIn != csize || inf.TotalOut != size)) {

// A csize of -1 is from an unpatched local header
if ((flags & 8) == 0 &&
(inf.TotalIn != csize && csize != 0xFFFFFFFF && csize != -1 || inf.TotalOut != size)) {
throw new ZipException("Size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut);
}
inf.Reset();
Expand Down

0 comments on commit cfc69a6

Please sign in to comment.