[
  {
    "Id": "904753",
    "ThreadId": "393255",
    "Html": "\r\n<p>I have created a set of zip files using dotnetzip library using the following</p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><span style=\"color:blue\">using</span> (ZipFile zip = <span style=\"color:blue\">new</span> ZipFile())\r\n{\r\n   <span style=\"color:blue\">if</span> (chkEncryption.Checked)\r\n   {\r\n      zip.Encryption = EncryptionAlgorithm.WinZipAes256;\r\n      zip.Password = textPassword.Text;\r\n   }\r\n   zip.AddDirectory(DirectoryToZip);\r\n   zip.Comment = <span style=\"color:#a31515\">&quot;Archive&quot;</span>;\r\n   zip.MaxOutputSegmentSize = 2 * 1024 * 1024; <span style=\"color:green\">//2MB</span>\r\n   zip.UseZip64WhenSaving = Zip64Option.Default;\r\n   zip.Save(ZipFileToCreate);\r\n}\r\n</pre>\r\n</div>\r\n<p>It creates the zip files without any errors. I then try to extract all files from the zip file and get the following error while extracting.</p>\r\n<p>&quot;Bad MAC address&quot;</p>\r\n<p>I am extracting using the following code:</p>\r\n<pre>file.Extract(textExtractLoc.Text, ExtractExistingFileAction.OverwriteSilently);</pre>\r\n<p>I am using version 1.9.1.8. I tried to create and extract using the tool provided in the package with the same error.</p>\r\n<p>I did see that a similar issue was fixed in 1.9.1.6 and closed, but looks like this is still existing. Can you help?</p>\r\n<p>Thanks</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2012-08-27T13:42:28.77-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "904754",
    "ThreadId": "393255",
    "Html": "\r\n<p>Here is the exception</p>\r\n<div style=\"background-color:white; color:black\">\r\n<pre>[Ionic.Zip.BadStateException] = {Ionic.Zip.BadStateException: The MAC does not match.\r\n   at Ionic.Zip.WinZipAesCrypto.ReadAndVerifyMac(Stream s)\r\n   at Ionic.Zip.ZipEntry.VerifyCrcAfterExtract(Int32 actualCrc32)\r\n   at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, ...\r\n</pre>\r\n</div>\r\n<p>The error occurs only when encryption is turned on.</p>\r\n<p>thanks</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2012-08-27T13:45:39.417-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "908775",
    "ThreadId": "393255",
    "Html": "<p>I'm also seeing this exact same issue with v1.9.1.8</p>",
    "PostedDate": "2012-09-05T09:59:12.113-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "987580",
    "ThreadId": "393255",
    "Html": "\r\n<p><span style=\"font-size:10pt\">Same problem (I think) with 1.9.1.8 - &quot;The MAC does not match&quot;</span></p>\r\n<p><span style=\"font-size:10pt\"><br>\r\n</span></p>\r\n<p>I need a fix for this, otherwise this DotNETZip Library is completely unusable for me. I\r\n<span style=\"text-decoration:underline\">need</span>&nbsp;to programmatically split large data files.</p>\r\n<p>&nbsp;</p>\r\n<p>Is there a way for me to get my hands on the source code, debug it and fix it for everyone? I'm new to the whole CodePlex / open source thing... but I do have 20 years MS software development experience and am sure I could fix it in a flash... Any pointers\r\n would be appreciated. I don't want to spend weeks on this as I have a job. But if I can get involved in an evening or 2 of my spare time... then I'd be interested.</p>\r\n",
    "PostedDate": "2013-01-16T06:25:10.33-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "987858",
    "ThreadId": "393255",
    "Html": "\r\n<p>OK... once I downloaded the source, downloaded WiX, Silverlight developer stuff!! and got it running, it took me a little while to step through the code. But I got there in the end...</p>\r\n<p>&nbsp;</p>\r\n<p>Basically on line 946 of ZipEntry.Extract.cs (in the ZipDLL project), in a method named&nbsp;VerifyCrcAfterExtract, there is a call to&nbsp;WinZipAesCipherStream.ReadAndVerifyMac</p>\r\n<p>&nbsp;</p>\r\n<p>The ReadAndVerifyMac method&nbsp;assumes the Zip file stream we have been reading from is positioned at the end of the encrypted data for the last file that has been read out (and decrypted and inflated most probably).</p>\r\n<p>In my case, where I am only extracting one file from the Zip archive, the file stream was disposed of once the file data was readout. So the call below to ReadAndVerifyMac actually creates a whole new file stream that is positioned at the beginning of the\r\n file - and as you'd expect the call to ReadAndVerifyMac reads the completely wrong data from the file and fails.</p>\r\n<p>WinZipAesCipherStream wzs = _inputDecryptorStream as WinZipAesCipherStream;</p>\r\n<p>_aesCrypto_forExtract.CalculatedMac = wzs.FinalAuthentication;<br>\r\n_aesCrypto_forExtract.ReadAndVerifyMac(this.ArchiveStream); // throws if MAC is bad</p>\r\n<p>The call above to this.ArchiveStream recreates the file stream from scratch, as it has already been disposed of.</p>\r\n<p>A quick and dirty work around is to seek to the correct position in the file by executing the following line of code before the call to ReadAndVerifyMac -</p>\r\n<p>this.ArchiveStream.Position = __FileDataPosition + _CompressedFileDataSize;</p>\r\n<p>but a much better solution, avoiding the need to open a new file stream, is to read out and store the MAC from the file after the last encrypted/compressed data is read, but before the file stream is disposed of. For me that would be done in a method called</p>\r\n<p>private Int32 ExtractOne(Stream output)</p>\r\n<p>in the file ZipEntry.Extract.cs,&nbsp;<span>just before the end of the try block at line 1073.................</span></p>\r\n<p>&nbsp;</p>\r\n<p><span>Anyway, I have my fix and only have to worry about my own bugs now!</span></p>\r\n",
    "PostedDate": "2013-01-16T17:26:34.89-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]