This project is read-only.


Array out of bounds exception in finish()


I'm attempting to replace the built in Gzip with this library for a WCF project I'm working on now.The code in question is derived entirely from the WCF compression sample which can be found here:
In the sample project, just replace the System.IO.Compression (which works) with Ionic.Zlib and you should see it throw an exception when decompressing a Gzipped stream. I've debugged using source and can trace it to the finish() method (in ZlibBaseStream.cs - called by Dispose).
// workitem 8679
if (_z.AvailableBytesIn !=8)
// do an array copy of length _z.AvailableBytesIn
The problem is that in the aforementioned WCF sample, the _z.AvailableBytesIn is larger than 8 bytes. This causes an ArgumentException because the array you are trying to copy into (trailer) is only 8 bytes. I believe this is due to the way the WCF sample does buffered reads.
Anyway, I've attached a patch which simply changes the if statement to check for _z.AvailableBytesIn < 8. That fixed my issue and BTW I get much better compression ratios with this library than the built in System.IO.Compression. Thanks!

file attachments

Closed Jun 22, 2011 at 2:11 AM by Cheeso
Fixed in changeset 79583. The first release to contain this fix will be v1.9.1.6


bschloz wrote Nov 23, 2010 at 6:29 PM

Found another post which fixes the sample to properly calculate and write the compressed bytes to the buffer manager. This fixes the aforementioned bug and allows me to use the DotNetZip ZLib as released. Here is the post in case anyone is interested:

wrote Jun 17, 2011 at 4:26 AM

wrote Jun 22, 2011 at 2:11 AM

wrote Feb 22, 2013 at 2:43 AM

wrote May 16, 2013 at 1:31 PM