[
  {
    "Id": "141904",
    "ThreadId": "42704",
    "Html": "I have compressed a lot of files using an older version of DotNet Zip library. Now I have updated at version <span id=\"ctl00_ctl00_MasterContent_Content_TitleLabel\">1.6 and </span>when i try to unzip some files created using the older version, sometime I have an error: not a valid zip file. If&nbsp; I open these files using winzip or unzip these folders in Window XP I have no problem... they seem to be valid.<br>\r\nI have downloaded the source code and I have noticed that the problem is in the static method PackedToDateTime of the internal class SharedUtilities, namespace Ionic.Utils.Zip.<br>\r\nFor these not valid zip files, the second value calculated by this function is 60 so when the function try to create a new datetime value ( new System.DateTime(year, month, day, hour, minute, second, 0))&nbsp; I have a System.ArgumentOutOfRangeException. <br>\r\nProbably, in the older version, this is ignored and in this case then function retun System.DateTime.Now.<br>\r\n<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static DateTime PackedToDateTime(Int32 packedDateTime)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 packedTime = (Int16)(packedDateTime &amp; 0x0000ffff);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 packedDate = (Int16)((packedDateTime &amp; 0xffff0000) &gt;&gt; 16);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int year = 1980 + ((packedDate &amp; 0xFE00) &gt;&gt; 9);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int month = (packedDate &amp; 0x01E0) &gt;&gt; 5;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int day = packedDate &amp; 0x001F;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int hour = (packedTime &amp; 0xF800) &gt;&gt; 11;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int minute = (packedTime &amp; 0x07E0) &gt;&gt; 5;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //int second = packedTime &amp; 0x001F;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int second = (packedTime &amp; 0x001F) * 2;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DateTime d = System.DateTime.Now;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try { d = new System.DateTime(year, month, day, hour, minute, second, 0); }<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (System.ArgumentOutOfRangeException ex1)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new ZipException(&quot;Bad date/time format in the zip file.&quot;, ex1);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Console.WriteLine(&quot;exception formatting the date: {0}\\n\\n&quot;, ex1.ToString());<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Console.Write(&quot;\\nInvalid date/time?:\\nyear: {0} &quot;, year);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Console.Write(&quot;month: {0} &quot;, month);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Console.WriteLine(&quot;day: {0} &quot;, day);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Console.WriteLine(&quot;HH:MM:SS= {0}:{1}:{2}&quot;, hour, minute, second);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return d;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>\r\n<br>\r\nWhy is the header date so important to throw new ZipException?<br>\r\n",
    "PostedDate": "2008-12-19T09:56:39.247-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "141913",
    "ThreadId": "42704",
    "Html": "<div>yes -</div>\r\n<div>in v1.6, I added logic to set the timestamp on files as they are being unpacked. </div>\r\n<div>this means that older zip files with potentially out-of-range values for the timestamp will cause the new library to choke.</div>\r\n<div></div>\r\n<div>you can add this to the PackedToDateTime method: </div>\r\n<div>\r\n<pre>// validation and error checking.\r\n// this is not foolproof but will catch most errors.\r\nif (second &gt;= 60) {minute++; second=0;}\r\nif (minute &gt;= 60) {hour++; minute=0;}\r\nif (hour &gt;= 24) { day++; hour = 0; }\r\n\r\nDateTime d = System.DateTime.Now;\r\ntry { d = new System.DateTime(year, month, day, hour, minute, second, 0); }\r\n\r\n</pre>\r\n</div>\r\n<div></div>\r\n<div>or wait just a bit and I will back-port this fix to v1.6. </div>\r\n<div></div>\r\n<div></div>\r\n",
    "PostedDate": "2008-12-19T10:19:08.98-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "141916",
    "ThreadId": "42704",
    "Html": "thank you for reply and sorry for my bad english<br>\r\nI hope you fix it relatively soon.<br>\r\n<br>\r\nBye.<br>\r\n<br>\r\n",
    "PostedDate": "2008-12-19T10:32:53.733-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "141926",
    "ThreadId": "42704",
    "Html": "Ok, the validation of date/time is now available in the v1.6.3.15 release.  \r\n",
    "PostedDate": "2008-12-19T11:20:14.953-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "151403",
    "ThreadId": "42704",
    "Html": "similar problem with v1.6.3.18 of the dll.<div>zip file works in winzip, and unzip that comes with unixutils (<a href=\"http://sourceforge.net/projects/unxutils\">http://sourceforge.net/projects/unxutils)</a></div><div><br><div><div>ReadHeader can't seem to understand the block.</div><div><div><div>            ze._VersionNeeded = 20</div><div>            ze._BitField = 2</div><div>            ze._CompressionMethod = 8</div><div>            ze._TimeBlob = -1</div><div><br></div><div>here are the block bytes.</div><div>-<span style=\"white-space:pre\">\t\t</span>block<span style=\"white-space:pre\">\t</span>{Dimensions:[26]}<span style=\"white-space:pre\">\t</span>byte[]</div><div><span style=\"white-space:pre\">\t\t</span>[0]<span style=\"white-space:pre\">\t</span>20<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[1]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[2]<span style=\"white-space:pre\">\t</span>2<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[3]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[4]<span style=\"white-space:pre\">\t</span>8<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[5]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[6]<span style=\"white-space:pre\">\t</span>255<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[7]<span style=\"white-space:pre\">\t</span>255<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[8]<span style=\"white-space:pre\">\t</span>255<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[9]<span style=\"white-space:pre\">\t</span>255<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[10]<span style=\"white-space:pre\">\t</span>148<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[11]<span style=\"white-space:pre\">\t</span>98<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[12]<span style=\"white-space:pre\">\t</span>208<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[13]<span style=\"white-space:pre\">\t</span>121<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[14]<span style=\"white-space:pre\">\t</span>144<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[15]<span style=\"white-space:pre\">\t</span>23<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[16]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[17]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[18]<span style=\"white-space:pre\">\t</span>164<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[19]<span style=\"white-space:pre\">\t</span>86<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[20]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[21]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[22]<span style=\"white-space:pre\">\t</span>10<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[23]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[24]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><span style=\"white-space:pre\">\t\t</span>[25]<span style=\"white-space:pre\">\t</span>0<span style=\"white-space:pre\">\t</span>byte</div><div><br></div><div><br></div><div>the timestamp on the file is 1/13/2009 11:18am</div><div>any thoughts?</div><div><br></div><div>thx.</div><div>s.</div><div><br></div></div></div></div></div>",
    "PostedDate": "2009-01-27T08:57:24.057-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "153426",
    "ThreadId": "42704",
    "Html": "I don't remember ever seeing a specification that said a timestamp value of 0xffffffff was valid.  <br>\r\nAre you saying you have such a zip archive? <br>\r\nhow did you produce it?  With what tool?  <br>\r\n<br>\r\nWhen you extract the file with winzip or unixutils, does it get the timestamp you mentioned (1/13/2009, etc) ? <br>\r\n<br>\r\nIt shouldn't be difficult to insert some logic to handle the case where the timestamp is 0xFFFFFFFF.  But it would go into the v1.7 library, as v1.6 is already final. <br>\r\n<br>\r\nIf this is what you want, please file a workitem and upload the zip archive.<br>\r\n",
    "PostedDate": "2009-02-02T11:23:42.7-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "156894",
    "ThreadId": "42704",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://www.codeplex.com/DotNetZip/WorkItem/View.aspx?WorkItemId=7074\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-02-11T21:45:38.343-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "251328",
    "ThreadId": "42704",
    "Html": "<p>I usually use for work with zip files different tools.But once some important zip archives were damaged.And no one of these tools couldn't help me.And a friend recommended to me-<a title=\"corrupt zip files recovery software\" href=\"http://www.recoverytoolbox.com/recovery_zip_files.html\">corrupt zip files recovery software</a>.Software solved my problem easy and for free. <br><br></p>",
    "PostedDate": "2009-10-29T12:29:03.563-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]