skylot / jadx

Dex to Java decompiler
Apache License 2.0
41.81k stars 4.88k forks source link

Failed to parse '.arsc' file: IOException: Config size < 28 #1663

Closed jpstotz closed 2 years ago

jpstotz commented 2 years ago

Log level: Error Version: 1.4.4 Binary: jadx-gui-1.4.4-no-jre-win.exe File causing the error: resources.arsc.zip Java VM:

openjdk version "18.0.1.1" 2022-04-22
OpenJDK Runtime Environment (build 18.0.1.1+2-6)
OpenJDK 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

jadx Error:

ERROR: Failed to parse '.arsc' file
jadx.core.utils.exceptions.JadxException: Error decode: D:\download\browser\resources.arsc
    at jadx.api.ResourcesLoader.decodeStream(ResourcesLoader.java:78)
    at jadx.core.dex.nodes.RootNode.loadResources(RootNode.java:173)
    at jadx.api.JadxDecompiler.load(JadxDecompiler.java:122)
    at jadx.gui.JadxWrapper.open(JadxWrapper.java:65)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.IOException: Config size < 28
    at jadx.core.xmlgen.ResTableParser.parseConfig(ResTableParser.java:373)
    at jadx.core.xmlgen.ResTableParser.parseTypeChunk(ResTableParser.java:221)
    at jadx.core.xmlgen.ResTableParser.parsePackage(ResTableParser.java:162)
    at jadx.core.xmlgen.ResTableParser.decodeTableChunk(ResTableParser.java:110)
    at jadx.core.xmlgen.ResTableParser.decode(ResTableParser.java:86)
    at jadx.core.xmlgen.ResDecoder.decode(ResDecoder.java:28)
    at jadx.core.dex.nodes.RootNode.lambda$loadResources$7(RootNode.java:173)
    at jadx.api.ResourcesLoader.decodeStream(ResourcesLoader.java:61)
    ... 6 common frames omitted

Originally posted by @oxou in https://github.com/skylot/jadx/issues/178#issuecomment-1235626628

jpstotz commented 2 years ago

@oxou Thanks for the sample.

Jadx currently has two problems with this sample:

  1. Our ResTableParser.parsePackage reads a very large size that can not be correct for the package chunk. Apktool seems to ignore the size and simple reads until it encounters a chunk of an unknown type.

  2. Modifying Jadx to read the chunks the same way as apktool does we run into a chunk of type 0x0203 = TYPE_LIBRARY (called Header.XML_TYPE_LIBRARYin apktool). We don't have any code yet for loading such a chunk.