Jar File Not Accessible in Recaf V3/V4 Due to Missing Central Directory Header and zero-length Local File Directory Header entries
Describe the bug
I made my own program that takes a jar file by input to detect and remove a spigot backdoor but the output jar file cannot be accessed by V3 or V4 due to an "No Central-Directory-File-Reader found" error, it is accessible in V2 though.
I forgot to close the output stream which I assume caused the zip headers to not be written correctly but since it works in the JVM regardless of this I thought I might as well mention it. I had to upload it to media fire because github doesn't recognize it as a zip file.
To Reproduce
Steps to reproduce the behavior:
- Open sample in Recaf V3/V4
Exception
14:25:27.680 [BasicResourceImporter/path-loader-0] INFO : Reading input from ZIP container 'viaversionfixed.jar'
14:25:27.716 [WorkspaceExplorerPane/path-loader-0] ERROR: Failed to create new workspace from dropped files
java.io.IOException: No Central-Directory-File-Header found!
at software.coley.lljzip.format.read.JvmZipReader.read(JvmZipReader.java:68)
at software.coley.lljzip.ZipIO.read(ZipIO.java:257)
at software.coley.lljzip.ZipIO.read(ZipIO.java:197)
at software.coley.recaf.services.workspace.io.ResourceImporterConfig.lambda$mapping$0(ResourceImporterConfig.java:65)
at software.coley.collections.func.UncheckedFunction.apply(UncheckedFunction.java:17)
at software.coley.recaf.services.workspace.io.BasicResourceImporter.handleZip(BasicResourceImporter.java:142)
at software.coley.recaf.services.workspace.io.BasicResourceImporter.handleSingle(BasicResourceImporter.java:107)
at software.coley.recaf.services.workspace.io.BasicResourceImporter.importResource(BasicResourceImporter.java:592)
at software.coley.recaf.services.workspace.io.BasicResourceImporter$Proxy$_$$_WeldClientProxy.importResource(Unknown Source)
at software.coley.recaf.workspace.PathLoadingManager.lambda$asyncNewWorkspace$2(PathLoadingManager.java:84)
at software.coley.recaf.util.threading.ThreadUtil.lambda$wrap$2(ThreadUtil.java:224)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1570)
Opens fine for me
Default IO/ZIP parse settings
I accidentally uploaded the wrong one to mediafire my bad. This one should be the correct one. https://www.mediafire.com/file/6wx96oqrmmer25p/viaversion-fixed.jar/file
With your modified one:
Recaf can understand what files there are in the zip if you use the Naive strategy, but because the file entries are all sized at ZERO it will skip the associated file data and go to the next header. As the name implies, its naive. The file lengths were normally stored in the central file headers not the local file headers, and your modified file only has the local file headers. No central file headers, no end header, so Naive won't read the content.
I may add some options to the naive handling later at some point.
f18c86d96b584fe4fe82efd5df21497cee2a1b8a - Forgot to close this when I added it.