Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jar File Not Accessible in Recaf V3/V4 Due to Missing Central Directory Header and zero-length Local File Directory Header entries #887

Open
RareHyperIonYT opened this issue Nov 25, 2024 · 3 comments
Labels
3rd party problem A bug/problem but caused by a library usage Not a bug, but a question/problem regarding usage

Comments

@RareHyperIonYT
Copy link

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:

  1. 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)
@Col-E
Copy link
Owner

Col-E commented Nov 25, 2024

Opens fine for me

image

Default IO/ZIP parse settings

image

@Col-E Col-E added the Can't reproduce "It works on my machine!" label Nov 25, 2024
@RareHyperIonYT
Copy link
Author

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

@Col-E
Copy link
Owner

Col-E commented Nov 26, 2024

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.

@Col-E Col-E added usage Not a bug, but a question/problem regarding usage 3rd party problem A bug/problem but caused by a library and removed Can't reproduce "It works on my machine!" labels Nov 26, 2024
@Col-E Col-E changed the title Jar File Not Accessible in Recaf V3/V4 Due to Missing Central Directory Header Jar File Not Accessible in Recaf V3/V4 Due to Missing Central Directory Header and zero-length Local File Directory Header entries Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party problem A bug/problem but caused by a library usage Not a bug, but a question/problem regarding usage
Projects
None yet
Development

No branches or pull requests

2 participants