{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "This is probably a bug, but I won&#39;t fix it unless and until I have a user scenario that requires it.  workitem 10684 looks reasonable, but I am deferring work on that unless and until people vote it up and express some stronger desire to have that function. ",
    "ClosedDate": "2011-06-18T14:01:31.307-07:00",
    "CommentCount": 0,
    "Custom": null,
    "Description": "Hi Dino,\n \nI think there's a bug in OffsetStream.Seek when using SeekOrigin.Current or SeekOrigin.End. Unfortunately, SharedUtils.FindSignature calls it with SeekOrigin.Current, which  I think this at least part of the problem in this thread - http://dotnetzip.codeplex.com/Thread/View.aspx?ThreadId=209615.\n \nThe following replacement code adds support for SeekOrigin.Current and SeekOrigin.End, but will almost definitely break other parts of the library that rely on the existing behaviour:\n \n        /// <summary>\n        /// Sets the position within the current stream.\n        /// </summary>\n        /// <param name=\"offset\"></param>\n        /// <param name=\"origin\"></param>\n        /// <returns></returns>\n        public override long Seek(long offset, System.IO.SeekOrigin origin)\n        {\n            // the original code only works for SeekOrigin.Begin\n            // return _innerStream.Seek(_originalPosition + offset, origin) - _originalPosition;\n            long innerPosition;\n            // work out the new absolute position in the base stream\n            switch(origin)\n            {\n                case SeekOrigin.Begin:\n                    innerPosition = _originalPosition + offset;\n                    break;\n                case SeekOrigin.Current:\n                    innerPosition = _innerStream.Position + offset;\n                    break;\n                case SeekOrigin.End:\n                    innerPosition = _innerStream.Length + offset;\n                    break;\n                default:\n                    throw new System.NotImplementedException();\n            }\n            // prevent seeking past start of virtual stream\n            if (innerPosition < _originalPosition) throw new System.IO.IOException(\"Cannot seek past start of stream.\");\n            // prevent seeking past end of virtual stream\n            // note: http://msdn.microsoft.com/en-us/library/system.io.stream.seek.aspx states that\n            // \"Seeking to any location beyond the length of the stream is supported.\", but we\n            // shouldn't be doing that with zip files (or should we?).\n            if (innerPosition >= _innerStream.Length) throw new System.IO.IOException(\"Cannot seek past end of stream.\");\n            // move relative to start of virtual stream\n            return _innerStream.Seek(innerPosition, SeekOrigin.Begin) - _originalPosition;\n        }\n \nAlso, I don't know whether this is by design, but the Length property is returning the length of the entire stream, not the embedded portion that it's wrapping. I don't know if that was your intention, or whether it's a bug - a possible replacement if so is below. Again, it will probably break existing code that expects the current behaviour.\n \npublic override long Length\n        {\n            get\n            {\n                // the actual length of the virtual stream is shortened by the original offset\n                // return _innerStream.Length;\n                return _innerStream.Length - _originalPosition;\n            }\n        }\n \nCheers,\n \nMike",
    "LastUpdatedDate": "2013-05-16T05:31:49.903-07:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2010-04-20T02:55:56.397-07:00",
    "Status": {
      "Name": "Closed",
      "Id": 4
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "OffsetStream Seek bug - partial fix",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 1,
    "Id": 10660
  },
  "FileAttachments": [],
  "Comments": []
}