remicuson / winzipaes

Automatically exported from code.google.com/p/winzipaes
0 stars 0 forks source link

Fails to extract files from zip subdirs on windows. If subdir does not physically exist before extraction - failure #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. C:\temp\test.zip contains the following encrypted entries
   file1.txt
   dir1/file2.txt
2.
String name  = "C:\\temp\\test.zip";
String pass  = "a12345";
String dir   = new File(fileName).getParent();
AesZipFileDecrypter zip = new AesZipFileDecrypter( new File(name) );
for( ExtZipEntry zipEntry : zipFile.getEntryList() ) {
   String name = dir + File.separator + zipEntry.getName();
   zipFile.extractEntry( zipEntry, new File(name), pass );
}

3. zipFile.extractEntry will fail to extract dir1/file2.txt
   since dir c:\temp\dir1 does not exist in Windows file system

What is the expected output? What do you see instead?
* Expected to extract all files. Extracts only the ones in root dir of zip 
unless dirs and subdirs in zip file match existing dirs on windows.

What version of the product are you using? On what operating system?
Latest  :) Windows XP

Please provide any additional information below.

In function extractEntry(...), file AesZipFileDecrypter right before
File tmpFile = new File( outFile.getPath() + "_TMP.zip" );
it requires to ensure that dir exists on the system

It can be done by adding statement
makeDir( new File( outFile.getParent()) );

--- here is implementation of makeDir

public static void makeDir(File dir) throws Exception {
  if (dir!=null) { 
    if (!dir.exists()) {
      File parentDir = new File(dir.getParent());
      if (!parentDir.exists()) makeDir(parentDir);
      dir.mkdir();
    }
  }
}

------- Regards

Original issue reported on code.google.com by ielis...@gmail.com on 26 Jan 2009 at 6:53

GoogleCodeExporter commented 8 years ago
added the makeDir() as proposed

Original comment by olaf.merkert on 10 Feb 2009 at 7:09

GoogleCodeExporter commented 8 years ago
Hello Olaf
I tried to use your code in a private project. So far I am very happy with it,
congratulations!
I use the library to extract files from an encrypted zip file (encrypted by 
winzip)
but when there are more than one file in it and in a subfolder as described 
above I
get the following exception:

Exception in thread "main" java.util.zip.ZipException: extra field is of length 
0 -
this is probably not a WinZip AES encrypted entry
    at
de.idyl.crypto.zip.impl.CentralDirectoryEntry.initFromRaFile(CentralDirectoryEnt
ry.java:109)
    at de.idyl.crypto.zip.impl.CentralDirectoryEntry.<init>(CentralDirectoryEntry.java:72)
    at de.idyl.crypto.zip.AesZipFileDecrypter.getEntryList(AesZipFileDecrypter.java:96)

I hope that this project is still active and looking forward to getting your 
response.

Best regards
Christian

Original comment by christia...@gmail.com on 4 Mar 2010 at 8:00

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi Chris,

can you add the zip file you used? Are you sure, that its AES encrypted?

Cheers,
Olaf

Original comment by olaf.merkert on 4 Mar 2010 at 6:01

GoogleCodeExporter commented 8 years ago
Hi Olaf

I post the source file of my small test app and the encrypted zip file. I 
encrypted
it using winzip 12.

Thanks a lot
Best regards
Christian

Original comment by christia...@gmail.com on 9 Mar 2010 at 8:34

Attachments:

GoogleCodeExporter commented 8 years ago
sorry, sorry - as I mentioned in the project's brief description: it started 
out as a
creator for aes encrypted zip files and only upon public demand now supports the
decryption as well - but unfortunately less quality assured as the encryption - 
the
problem was, that: a) directories are zip file entries as well and b) I added 
some
plausibility checks to make sure the zip entries are read from the right place 
within
the file - in the latter part, the directories (and non-encrypted files) were 
not
handled correctly - added some testcases to verfy the corrections

Original comment by olaf.merkert on 21 Mar 2010 at 7:49