Skip to content

Commit cfc69a6

Browse files
author
David Pierson
committed
Z-1663 Fixed exception extracting an unpatched local header when compressed size is -1
1 parent af7f243 commit cfc69a6

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

doc/Changes.txt

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Changes for 0.86.0
2+
+ Multi-member gzip files are now supported. Contributed by Geoff Hart.
3+
+ Zero byte files caused ZipOutputStream to create invalid zipfiles. Contributed by Mark Ritchie.
4+
+ ZipFile.CommitUpdate failed on ODT (Open Document) files when updating in memory. Contributed by Dricks.
5+
+ Exceptions occurring within ZipFile.CommitUpdate were being silently discarded.
6+
+ In FastZip, the NameFilter erroneously removed all escapes from regex. Contributed by John Lemberger.
7+
Note: This is a breaking change - if you had detoured this filter bug via doubled-up backslashes,
8+
please halve them - for example change @"\\\\myextract.txt$" to @"\\myextract.txt$", or
9+
change "\\\\\\\\myextract.txt$" to "\\\\myextract.txt$".
10+
+ AES Encryption and Decryption is now supported.
11+
+ TarArchive now has IsStreamOwner property, for use with MemoryStream.
12+
+ Removed exception "Extra data contains Zip64 information but version 2.0 is not high enough" due to rogue zip creators.
13+
+ FastZip.ExtractZip now accepts an Input Stream.
14+
+ Zip input and output streams can now specify buffer sizes.
15+
+ Solved "NTFS Extra data invalid" exception when reading zip files with zero-length NTFS ExtraData entry.
16+
+ Fixed "Size mismatch" exceptions reading zips created by SharpZipLib with an explicit entry CRC and Size.
17+
18+
119
Changes for 0.85.5
220
+ Fix for unreferenced ZipFile causing read failure after garbage collection.
321
+ Fix to ZipInputStream.CloseEntry were skipping could fail for long values.

src/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
[assembly: AssemblyCopyright("Copyright 2001-2010 Mike Krueger, John Reilly")]
7878
[assembly: AssemblyTrademark("Copyright 2001-2010 Mike Krueger, John Reilly")]
7979

80-
[assembly: AssemblyVersion("0.86.0.516")]
80+
[assembly: AssemblyVersion("0.86.0.518")]
8181
[assembly: AssemblyInformationalVersionAttribute("0.86.0")]
8282

8383

src/Zip/ZipFile.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
// HISTORY
4141
// 2009-12-22 Z-1649 Added AES support
4242
// 2010-03-02 Z-1650 Fixed updating ODT archives in memory. Exposed exceptions in updating.
43+
// 2010-05-25 Z-1663 Fixed exception when testing local header compressed size of -1
4344

4445
using System;
4546
using System.Collections;
@@ -1255,7 +1256,8 @@ long TestLocalHeader(ZipEntry entry, HeaderTest tests)
12551256
entry.Size, size));
12561257
}
12571258

1258-
if (compressedSize != entry.CompressedSize) {
1259+
if (compressedSize != entry.CompressedSize &&
1260+
compressedSize != 0xFFFFFFFF && compressedSize != -1) {
12591261
throw new ZipException(
12601262
string.Format("Compressed size mismatch between central header({0}) and local header({1})",
12611263
entry.CompressedSize, compressedSize));

src/Zip/ZipInputStream.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
// obligated to do so. If you do not wish to do so, delete this
3838
// exception statement from your version.
3939

40+
// HISTORY
41+
// 2010-05-25 Z-1663 Fixed exception when testing local header compressed size of -1
42+
4043
using System;
41-
using System.Text;
4244
using System.IO;
4345

4446
using ICSharpCode.SharpZipLib.Checksums;
@@ -613,8 +615,10 @@ int BodyRead(byte[] buffer, int offset, int count)
613615
throw new ZipException("Inflater not finished!");
614616
}
615617
inputBuffer.Available = inf.RemainingInput;
616-
617-
if ((flags & 8) == 0 && (inf.TotalIn != csize || inf.TotalOut != size)) {
618+
619+
// A csize of -1 is from an unpatched local header
620+
if ((flags & 8) == 0 &&
621+
(inf.TotalIn != csize && csize != 0xFFFFFFFF && csize != -1 || inf.TotalOut != size)) {
618622
throw new ZipException("Size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut);
619623
}
620624
inf.Reset();

0 commit comments

Comments
 (0)