{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "fixed in v1.7.2.2",
    "ClosedDate": "2009-02-11T22:07:37.433-08:00",
    "CommentCount": 0,
    "Custom": null,
    "Description": "all the references to buffer.Length inside the method must be changed in references to the count parameter.\nThe current implementation does not work if Read is called with count != buffer.Length, e.g. when offset > 0\nThe impact is a strange behaviour of the stream returned by ZipEntry.OpenReader",
    "LastUpdatedDate": "2013-05-16T05:32:33.137-07:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2009-01-13T03:37:36.92-08:00",
    "Status": {
      "Name": "Closed",
      "Id": 4
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "bug in ZlibBaseStream.Read",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 1,
    "Id": 6913
  },
  "FileAttachments": [],
  "Comments": [
    {
      "Message": "Can you give me some test code to demonstrate this problem, so I can produce a unit test for this case? ",
      "PostedDate": "2009-01-14T06:13:54.09-08:00",
      "Id": -2147483648
    },
    {
      "Message": "Code fix is in changeset 27627.  no unit tests yet.",
      "PostedDate": "2009-01-14T07:11:59.083-08:00",
      "Id": -2147483648
    },
    {
      "Message": "I am not sure in what form you need the code.\r\nI discovered the bug because I was reading into a buffer that way:\r\nfirst Read 4 bytes at offset 0.\r\ncompute a length n with that data\r\nread n - 4 bytes at offset 4 in the buffer\r\nprocess the buffer (with only n initialized bytes)\r\nMy buffer was sized once to be big enough for all records of the file\r\n(a binary format with records whose length in encoded in beginning of the record).\r\nWith the previous code, you were always reading buffer.Length bytes, which could work only if the offset was 0.",
      "PostedDate": "2009-01-19T01:47:00.333-08:00",
      "Id": -2147483648
    },
    {
      "Message": "I mostly understand what you are saying but there is no substitute for code.  I want the code you use - in the form of a VB or CS file.  Not in english.  In C#.  ",
      "PostedDate": "2009-01-19T20:34:11.94-08:00",
      "Id": -2147483648
    },
    {
      "Message": "my code is as follows, and I called it it with the stream returned by OpenReader() on an entry\r\nI would not like to provide the actual files I used, because content is not public\r\n\r\n    public static class KWPReader\r\n    {\r\n        public static IEnumerable<Request> Requests(this Stream stream)\r\n        {\r\n            if (stream == null)\r\n                throw new ArgumentNullException(\"stream\");\r\n            if (!stream.CanRead)\r\n                throw new ArgumentException(\"file : can't read\");\r\n            //if (stream.Position != 0)\r\n            //{\r\n            //    if (!stream.CanSeek)\r\n            //        throw new ArgumentException(\"file : can't seek\");\r\n            //    stream.Seek(0, SeekOrigin.Begin);\r\n            //}\r\n            byte[] buffer = new byte[260];\r\n            do\r\n            {\r\n                int n = stream.Read(buffer, 0, 4);\r\n                if (n == 0)\r\n                    yield break;\r\n                if (n < 4)\r\n                    throw new InvalidOperationException();\r\n                int l = buffer[0] & 0x3f;\r\n                int h = 3;\r\n                if (l == 0)\r\n                {\r\n                    l = buffer[3];\r\n                    h = 4;\r\n                }\r\n                int nb = l + h + 1;\r\n                int m = nb - 4;\r\n                n = stream.Read(buffer, 4, m);\r\n                if (n < m)\r\n                    throw new InvalidOperationException();\r\n                int cks = 0;\r\n                for (int i = 0; i < nb - 1; i++)\r\n                    cks += buffer[i];\r\n                if ((cks & 0xff) != buffer[nb - 1])\r\n                    throw new InvalidOperationException();\r\n                yield return new Request(buffer[1], buffer[2], buffer, h, l); ;\r\n            } while (true);\r\n        }\r\n}",
      "PostedDate": "2009-01-20T03:27:16.65-08:00",
      "Id": -2147483648
    },
    {
      "Message": "Can you try the latest v1.7.2.2 to see if it works for your purposes?    I Think I've fixed it but I don't have a unit test to verify it.\r\n",
      "PostedDate": "2009-02-09T15:47:53.537-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2009-02-11T22:07:37.433-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-02-21T18:44:33.617-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-05-16T05:32:33.137-07:00",
      "Id": -2147483648
    }
  ]
}