{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "fixed in changeset &#35;42377",
    "ClosedDate": "2009-09-05T09:22:06.697-07:00",
    "CommentCount": 0,
    "Custom": null,
    "Description": "When using GZipStream to decompress a stream where the stream length is a multiple of the buffer size + header size +(0 to 7), an exception is generated thus:\n \nProtocol error. AvailableBytesIn=7, expected 8\n \nAvailableBytesIn varying between 0 and 7.  This happens because the read routine stops reading the base stream when all the compressed data is complete: if the trailing 8 bytes (CRC, size) didn't fit into the buffer the finish() routine in ZlibStream.cs throws the above exception.  I have written a fix in zlibstream.cs (starts at line 885):\n \n                        // Read and potentially verify the GZIP trailer: CRC32 and  size mod 2^32\n                        byte[] trailer = new byte[8];\n \n                        //>>>> OLD CODE >>>>\n                        //if (_z.AvailableBytesIn != 8)\n                        //    throw new ZlibException(String.Format(\"Protocol error. AvailableBytesIn={0}, expected 8\",\n                        //         _z.AvailableBytesIn));\n                        //\n                        //Array.Copy(_z.InputBuffer, _z.NextIn, trailer, 0, trailer.Length);\n                        //>>>\n                        //<<<< NEW CODE <<<<\n \n                        if (_z.AvailableBytesIn != 8)\n                        {\n                            //  Make sure we have read to the end of the stream\n                            Array.Copy(_z.InputBuffer, _z.NextIn,trailer, 0, _z.AvailableBytesIn);\n                            int bytesNeeded = 8 - _z.AvailableBytesIn;\n                            int bytesRead = _stream.Read(trailer,\n                                                         _z.AvailableBytesIn,\n                                                         bytesNeeded);\n                            if (bytesNeeded != bytesRead)\n                            {\n                                throw new ZlibException(String.Format(\"Protocol error. AvailableBytesIn={0}, expected 8\",\n                                     _z.AvailableBytesIn + bytesRead));\n                            }\n                        }\n                        else\n                        {\n                            Array.Copy(_z.InputBuffer, _z.NextIn, trailer, 0, trailer.Length);\n                        }\n \n                        // <<<< END NEW CODE\n \nTo make it easier to verify, I'm attaching a gzipped file that causes problems when the buffer size is the default 8192 bytes.",
    "LastUpdatedDate": "2013-05-16T05:32:09.94-07:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2009-09-04T08:48:14.953-07:00",
    "Status": {
      "Name": "Closed",
      "Id": 4
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "Zlib exception when compressed stream size is (multiple of buffer size) + header size +(0 to 7)",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 1,
    "Id": 8679
  },
  "FileAttachments": [
    {
      "FileId": 2274,
      "FileName": "problem.gz",
      "DownloadUrl": ".\\2274"
    }
  ],
  "Comments": [
    {
      "Message": "I Love bug reports that come with proposed fix code. Thanks!",
      "PostedDate": "2009-09-05T08:53:11.697-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2009-09-05T09:22:06.697-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-02-21T18:44:02.77-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-05-16T05:32:09.94-07:00",
      "Id": -2147483648
    }
  ]
}