Skip to content

ICSharpCode.SharpZipLib.Zip.ZipException Wrong Local header signature #649

@mattkemp

Description

@mattkemp

Full error: ICSharpCode.SharpZipLib.Zip.ZipException: 'Wrong Local header signature: 0x1861C282'

Thrown at the s.GetNextEntry() point below

ZipInputStream s = new ZipInputStream(File.OpenRead(zipPathAndFile));
if (password != null && password != String.Empty)
	s.Password = password;
ZipEntry theEntry;
string tmpEntry = String.Empty;
while ((theEntry = s.GetNextEntry()) != null) {

It doesn't seem to be an error with actual zip file, 21 files out of 39 unzip ok, it just gets stuck on one (always the same one).

Here's some info from a QuickWatch on the "s" variable (ZipInputStream) and "theEntry" (ZipEntry)

s	{ICSharpCode.SharpZipLib.Zip.ZipInputStream}	ICSharpCode.SharpZipLib.Zip.ZipInputStream
		Available	0	int
		CanDecompressEntry	false	bool
		CanRead	true	bool
		CanSeek	false	bool
		CanTimeout	false	bool
		CanWrite	false	bool
		IsStreamOwner	true	bool
			Length	's.Length' threw an exception of type 'System.InvalidOperationException'	long {System.InvalidOperationException}
			Data	{System.Collections.ListDictionaryInternal}	System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
			HResult	-2146233079	int
			HelpLink	null	string
			InnerException	null	System.Exception
			Message	"No current entry"	string
			Source	"ICSharpCode.SharpZipLib"	string
			StackTrace	"   at ICSharpCode.SharpZipLib.Zip.ZipInputStream.get_Length()"	string
			TargetSite	{Int64 get_Length()}	System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
			Static members		
			Non-Public members		
		Password	null	string
		Position	716099584	long
		ReadTimeout	's.ReadTimeout' threw an exception of type 'System.InvalidOperationException'	int {System.InvalidOperationException}
		WriteTimeout	's.WriteTimeout' threw an exception of type 'System.InvalidOperationException'	int {System.InvalidOperationException}
		csize	677686656	long
		inf	{ICSharpCode.SharpZipLib.Zip.Compression.Inflater}	ICSharpCode.SharpZipLib.Zip.Compression.Inflater
			Adler	0	int
			IsFinished	false	bool
			IsNeedingDictionary	false	bool
			IsNeedingInput	true	bool
			RemainingInput	0	int
			TotalIn	0	long
			TotalOut	0	long
			Static members		
			Non-Public members		
			inputBuffer	{ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputBuffer}	ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputBuffer
			Available	2165	int
			ClearText	{byte[4096]}	byte[]
			ClearTextLength	4096	int
			RawData	{byte[4096]}	byte[]
			RawLength	4096	int
			Non-Public members		

theEntry	{CCCR.csv}	ICSharpCode.SharpZipLib.Zip.ZipEntry
		AESKeySize	0	int
		CanDecompress	true	bool
		CentralHeaderRequiresZip64	false	bool
		Comment	null	string
		CompressedSize	677686656	long
		CompressionMethod	Deflated	ICSharpCode.SharpZipLib.Zip.CompressionMethod
		Crc	1402703020	long
		DateTime	{13/07/2021 10:39:02 PM}	System.DateTime
		DosTime	1391310049	long
		ExternalFileAttributes	-1	int
		ExtraData	null	byte[]
		Flags	2056	int
		HasCrc	true	bool
		HostSystem	0	int
		IsCrypted	false	bool
		IsDOSEntry	true	bool
		IsDirectory	false	bool
		IsFile	true	bool
		IsUnicodeText	true	bool
		LocalHeaderRequiresZip64	false	bool
		Name	"CCCR.csv"	string
		Offset	0	long
		Size	0	long
		Version	20	int
		VersionMadeBy	51	int
		ZipFileIndex	-1	long
		Non-Public members		
			AESEncryptionStrength	0	byte
			AESOverheadSize	12	int
			AESSaltLen	0	int
			CompressionMethodForHeader	Deflated	ICSharpCode.SharpZipLib.Zip.CompressionMethod
			CryptoCheckValue	180	byte
			EncryptionOverheadSize	0	int
			_aesEncryptionStrength	0	int
			_aesVer	0	int
			comment	null	string
			compressedSize	677686656	ulong
			crc	1402703020	uint
			cryptoCheckValue_	180	byte
			dateTime	{13/07/2021 10:39:02 PM}	System.DateTime
			externalFileAttributes	-1	int
			extra	null	byte[]
			flags	2056	int
			forceZip64_	false	bool
			known	Size | CompressedSize | Crc | Time	ICSharpCode.SharpZipLib.Zip.ZipEntry.Known
			@method	Deflated	ICSharpCode.SharpZipLib.Zip.CompressionMethod
			name	"CCCR.csv"	string
			offset	0	long
			size	0	ulong
			versionMadeBy	51	ushort
			versionToExtract	20	ushort
			zipFileIndex	-1	long

Steps to reproduce

  1. try to unzip a file created by java "jar" command. I will try and get an example file with no client specific information and add to this issue. This zip file is being created by a third party and I have no control over it. I'm trying to find out what version of java/jar is being used.

Expected behavior

This header signature of the file inside the zip should not throw an error, 7zip and DotNetZip handle it

Actual behavior

Exception thrown as above

Version of SharpZipLib

1.3.2.10

Obtained from

  • Package installed using NuGet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions