Recaf icon indicating copy to clipboard operation
Recaf copied to clipboard

Give proper user notification for corrupted Jars

Open Geolykt opened this issue 4 years ago • 2 comments

In my case I had a jar that had no zip END header, which of course leads to the jar not being usable. However the UI does not make this clear right away (other than the loading freezing very early) and the only thing making this fact apparent is the output of the console. Perhaps maybe give a warning in that case? Example jar that causes this issue (renamed to .zip due to github's file extension limitation; I also own all rights to it) proof-of-concept.zip

Geolykt avatar Apr 18 '21 17:04 Geolykt

If anyone is aware of some ZIP libraries, or any different handling than what we do now (NIO?), for Java that handle this I can take a look at this. The default ZIP classes error out on the constructor, so its not really possible to cleanly work around this.

Crash since it reads the whole file before letting you visit each sub-item

java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:225)
	at java.util.zip.ZipFile.<init>(ZipFile.java:155)
	at java.util.zip.ZipFile.<init>(ZipFile.java:169)

Col-E avatar Apr 25 '21 20:04 Col-E

For additional context, the zip file is usually comprised of 3 structs:

  • LocalFileHeader
    • Has the file contents and metadata
  • CentralDirectoryFileHeader
    • Has metadata, which trumps the LocalFileHeader's
  • EndOfCentralDirectory
    • Info about number of expected entries

This sample contains only LocalFileHeader entries.

Col-E avatar Dec 05 '21 12:12 Col-E

This has been vastly improved in 3x and even more in 4x which even lets you choose between 3 modes of ZIP parsing. Gonna call this done for now.

Col-E avatar Sep 13 '23 02:09 Col-E