1

Closed

Issue with static Zlib UncompressBuffer method

description

Try this test:
 
private static readonly string filePath = "http://www.usbr.gov/recreation/publications/02_SampleBusinessPlan.doc";
    static void Main(string[] args)
    {
        Console.WriteLine("Downloading test doc...");
        WebClient wc = new WebClient();
        byte[] initialData = wc.DownloadData(filePath);
        wc.Dispose();
        Console.WriteLine("Initial size: " + initialData.Length.ToString());
        Console.WriteLine("Times are in ms. Sizes are in bytes.");
        Stopwatch sw = new Stopwatch();
        sw.Start();
        byte[] results8 = Ionic.Zlib.ZlibStream.CompressBuffer(initialData);
        sw.Stop();
        Console.WriteLine("Compress with DotNetZip: " + sw.ElapsedMilliseconds.ToString());
        Console.WriteLine("Compressed size: " + results8.Length.ToString());
        sw.Reset();
        sw.Start();
        byte[] newResults8 = Ionic.Zlib.ZlibStream.UncompressBuffer(results8);
        sw.Stop();
        Console.WriteLine("Decompress with DotnetZip: " + sw.ElapsedMilliseconds.ToString());
        Console.WriteLine("Decompressed size: " + newResults8.Length.ToString());
        Console.WriteLine("=========================================================");
        sw.Reset();
    }
Closed Aug 3, 2011 at 5:36 PM by Cheeso
Duplicate of http://dotnetzip.codeplex.com/workitem/10562. This is fixed in v1.9.1.6.

comments

Pointy wrote Aug 10, 2010 at 2:53 PM

Hi pbromberg.

Can you confirm what result you get when you run the test?

I get this output:

"Downloading test doc...
Initial size: 2492928
Times are in ms. Sizes are in bytes.
Compress with DotNetZip: 1344
Compressed size: 1364343"

followed by this exception:

Ionic.Zlib.ZlibException was unhandled
Message="Bad state (incorrect data check)"
Source="Ionic.Zlib"
StackTrace:
   at Ionic.Zlib.InflateManager.Inflate(FlushType flush) in C:\temp\dotnetzip.codeplex.com\svn_original\Zlib\Inflate.cs:line 1690
   at Ionic.Zlib.ZlibCodec.Inflate(FlushType flush) in C:\temp\dotnetzip.codeplex.com\svn_original\Zlib\ZlibCodec.cs:line 358
   at Ionic.Zlib.ZlibBaseStream.Read(Byte[] buffer, Int32 offset, Int32 count) in C:\temp\dotnetzip.codeplex.com\svn_original\Zlib\ZlibBaseStream.cs:line 477
   at Ionic.Zlib.ZlibStream.Read(Byte[] buffer, Int32 offset, Int32 count) in C:\temp\dotnetzip.codeplex.com\svn_original\Zlib\ZlibStream.cs:line 521
   at Ionic.Zlib.ZlibBaseStream.UncompressBuffer(Byte[] compressed, Stream decompressor) in C:\temp\dotnetzip.codeplex.com\svn_original\Zlib\ZlibBaseStream.cs:line 615
   at Ionic.Zlib.ZlibStream.UncompressBuffer(Byte[] compressed) in C:\temp\dotnetzip.codeplex.com\svn_original\Zlib\ZlibStream.cs:line 676
   at ConsoleApplication1.Program.Main(String[] args) in C:\temp\dotnetzip.codeplex.com\debug\WorkItem_11699\ConsoleApplication1\ConsoleApplication1\Program.cs:line 30
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException:

It's possibly a duplicate of [workitem:10562] . I've tried the same test using a private build with the fixes I posted there and I get the following:

"Downloading test doc...
Initial size: 2492928
Times are in ms. Sizes are in bytes.
Compress with DotNetZip: 1358
Compressed size: 1364343
Decompress with DotnetZip: 126
Decompressed size: 2492928
========================================================="

with the decompressed buffer identical to the original downloaded file.

Cheers,

Mike

Pointy wrote Aug 10, 2010 at 2:54 PM

Gah. Link fail.

http://dotnetzip.codeplex.com/workitem/10562 - Compression roundtrip problem