[
  {
    "Id": "474313",
    "ThreadId": "221863",
    "Html": "<p>I have old code that uses zlib library from zlib.net and I am trying out this DotNetZip library to use in my new code.</p>\r\n<p>I can deflate the data from the zlib code with DotNetZip, but the zlib code cannot deflate the last block of buffer data from DotNetZip library, so I get invalid data.</p>\r\n<p>I have gone through the code for both libraries and I can see they are mostly the same and I just can't figure out what is causing the problem. This is what happens, the last 4 bytes in the result file are not the same and everything else is same.</p>\r\n<p>I am sending buffer of size 3462929, and in the last loop the value in _codec.Adler32 = 3654184877, which converts to the last 4 bytes =<span style=\"color:#ff0000\"> D9 CE </span>6F AD.</p>\r\n<p>Same buffer goes via the zlib.net code and the value in adler = 2943381421, which converts the last 4 bytes = <span style=\"color:#ff0000\">AF 70 </span>6F AD.</p>\r\n<p>It's always the first 2 of the&nbsp;4 last bytes that are different, if you get what I mean.</p>\r\n<p>This is the code block I am using and its same for both libraries, I just switch the using statement and the ZlibStream object between test</p>\r\n<pre style=\"color:black;background-color:white\"><pre>FileStream outFileStream = <span style=\"color:blue\">new</span> FileStream(outfile, FileMode.Create); \r\nZLibStream outZStream = <span style=\"color:blue\">new</span> ZLibStream(outFileStream, CompressionMode.Compress); \r\nFileStream inFileStream = <span style=\"color:blue\">new</span> FileStream(infile, FileMode.Open);\r\n\r\n<span style=\"color:blue\">int</span> flen = (<span style=\"color:blue\">int</span>)inFileStream.Length; \r\n<span style=\"color:blue\">byte</span>[] buffer = <span style=\"color:blue\">new</span> <span style=\"color:blue\">byte</span>[flen + 1]; \r\n<span style=\"color:blue\">int</span> len; \r\n\r\n<span style=\"color:blue\">while</span> ((len = inFileStream.Read(buffer, 0, flen)) &gt; 0) \r\n{ \r\n  outZStream.Write(buffer, 0, len); \r\n} \r\noutZStream.Flush(); \r\n\r\n</pre>\r\n</pre>\r\n<pre style=\"color:black;background-color:white\">Edit:  I found out that if I compress small 3k xml file, both zip files are same, but if I try 3.4Mb binary data file, </pre>\r\n<pre style=\"color:black;background-color:white\">then the mixup in those 2 bytes happens.  I am using the DotNetZip lib and Zlib.net lib as is from both websides,</pre>\r\n<pre style=\"color:black;background-color:white\">just include them into the project and then run this code above 2 with different Stream objects.</pre>",
    "PostedDate": "2010-07-29T08:21:44.303-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "501916",
    "ThreadId": "221863",
    "Html": "<p>Hi,</p>\r\n<p>i have the same problem with managed zlib. The Adler32 from DotNetZip is different from that calulate in managed zlib.</p>\r\n<p>Also the Java inflater report incorrect data format when uncompressing the DotNetZip file but not the managed zlib file.</p>\r\n<p>So I assume that there is a bug in Dotnetzip's adler32 calculation.</p>\r\n<p>&nbsp;</p>\r\n<p>Any Idea's ?</p>\r\n<p>Thank's Stefan</p>",
    "PostedDate": "2010-10-04T01:58:06.007-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "501924",
    "ThreadId": "221863",
    "Html": "<p>I think the problem is an overflow issue in Adler32 if you&nbsp;specify a large buffer size. There's an int&nbsp;value in the code which can sometimes overflow depending on buffer size and data values and&nbsp;ends up&nbsp;giving&nbsp;the wrong Adler32 crc.</p>\r\n<p>You can try to reduce the size of &quot;flen&quot; in your program which will then sidestep the&nbsp;issue - anything less than 3980 bytes should avoid the problem.&nbsp;I also proposed a couple of different fixes to the Adler32 class in this thread <a href=\"http://dotnetzip.codeplex.com/workitem/10562\">http://dotnetzip.codeplex.com/workitem/10562</a>.</p>\r\n<p>Cheers,</p>\r\n<p>Mike</p>",
    "PostedDate": "2010-10-04T02:32:23.757-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "501953",
    "ThreadId": "221863",
    "Html": "<p>Hi Mike</p>\r\n<p>I tried out your code&nbsp;differences on my Library code and it solved the problem, now both compressed files compare same from both libraries.</p>\r\n<p>Thanks a lot</p>\r\n<p>Kristjan</p>",
    "PostedDate": "2010-10-04T03:47:32.947-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "502029",
    "ThreadId": "221863",
    "Html": "Thanks again, Mike. For the past several months I have not had a pc that works, nothing I could use to build and test DotNetZip. I'm hoping to rectify that and incorporate your fixes soon.  Glad to see you all helping each other out.",
    "PostedDate": "2010-10-04T07:00:28.18-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "502035",
    "ThreadId": "221863",
    "Html": "<p>No problem. Happy to help.</p>",
    "PostedDate": "2010-10-04T07:11:27.227-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]