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

[core] Not deterministic XML parsing error #1740

Closed
bagipro opened this issue Dec 3, 2022 · 2 comments
Closed

[core] Not deterministic XML parsing error #1740

bagipro opened this issue Dec 3, 2022 · 2 comments
Labels
bug Core Issues in jadx-core module

Comments

@bagipro
Copy link
Collaborator

bagipro commented Dec 3, 2022

Hey,

I've caught a really weird bug that throws the following error:

Error decode xml
java.lang.NullPointerException: Cannot read the array length because "this.resourceIds" is null
	at jadx.core.xmlgen.BinaryXMLParser.getAttributeName(BinaryXMLParser.java:361)
	at jadx.core.xmlgen.BinaryXMLParser.parseAttribute(BinaryXMLParser.java:304)
	at jadx.core.xmlgen.BinaryXMLParser.parseElement(BinaryXMLParser.java:282)
	at jadx.core.xmlgen.BinaryXMLParser.decode(BinaryXMLParser.java:125)
	at jadx.core.xmlgen.BinaryXMLParser.parse(BinaryXMLParser.java:81)

However, this error is thrown with a ~50% chance (in other cases this.resourceIds isn't null). In case of an error, you will see a stacktrace in output logs.

It leads to incorrect decoding of AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>>
...

and other XML files aren't decoded too

Arguments:

jadx --log-level error --output-dir OUT app.apk

APK: https://drive.google.com/file/d/1Sm0d0I1hYW_93HQUcCvt5nEYfMtRJAi-/view?usp=sharing

UPD:
I found a race condition in https://github.com/skylot/jadx/blob/master/jadx-core/src/main/java/jadx/core/xmlgen/ResourcesSaver.java#L32. If AndroidManifest.xml is processed first, no errors will happen. However, if other XML files are processed first, NullPointerException will be thrown and BinaryXMLParser will remain in a corrupted state and output extra >

@bagipro bagipro added bug Core Issues in jadx-core module labels Dec 3, 2022
@bagipro
Copy link
Collaborator Author

bagipro commented Jan 28, 2023

Hey!

Does anybody have an idea how it potentially can be fixed? Is RES_STRING_POOL_TYPE value always present in AndroidManifest.xml? If yes, there's a sense to process this file first.

Or it can be located in other XML files?

@skylot
Copy link
Owner

skylot commented Feb 17, 2023

Fixed. Not the best solution, but it should work 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

2 participants