sky201503 / android-apktool2

Automatically exported from code.google.com/p/android-apktool
0 stars 0 forks source link

StringIndexOutOfBoundsException when decompile Adobe Reader APK #196

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1) try to decompile an APK file "com.adobe.reader.apk" using the following 
command:

java -jar apktool1.4.2.269870b.jar d -com.adobe.reader.apk

What is the expected output? What do you see instead?
Got the following exception:

I: Baksmaling...
I: Loading resource table...
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String 
index out of range: 33471
    at java.lang.String.substring(String.java:1934)
    at brut.androlib.res.decoder.StringBlock.getHTML(StringBlock.java:161)
    at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:222)
    at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:177)
    at brut.androlib.res.decoder.ARSCDecoder.readConfig(ARSCDecoder.java:165)
    at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:130)
    at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:105)
    at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:82)
    at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:48)
    at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:315)
    at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:50)
    at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:43)
    at brut.androlib.Androlib.getResTable(Androlib.java:44)
    at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:148)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:98)
    at brut.apktool.Main.cmdDecode(Main.java:120)
    at brut.apktool.Main.main(Main.java:57)

What version of the product are you using? On what operating system?

apktool1.4.2.269870b.jar on Mac OS 10.7.4

Please provide any additional information below.

Original issue reported on code.google.com by dharm82...@gmail.com on 14 Jul 2011 at 9:06

Attachments:

GoogleCodeExporter commented 9 years ago
I got the same problem , anyone could help me ??

Original comment by aceti...@gmail.com on 22 Jul 2011 at 5:20

GoogleCodeExporter commented 9 years ago

Original comment by Brut.alll on 5 Nov 2011 at 8:55

GoogleCodeExporter commented 9 years ago
This isn't a 169.

Original comment by Brut.alll on 28 Nov 2011 at 11:28

GoogleCodeExporter commented 9 years ago
Not fixed in latest Apktool v1.5.2

Original comment by cskart...@gmail.com on 15 Mar 2013 at 7:10

GoogleCodeExporter commented 9 years ago
Don't think I've said I've fixed it.

This seems to be same problem with outdated XML parser library. Dmitry might 
help with this.

Original comment by connor.tumbleson on 16 Mar 2013 at 3:39

GoogleCodeExporter commented 9 years ago
Thanks Connor. 

Original comment by cskart...@gmail.com on 16 Mar 2013 at 2:02

GoogleCodeExporter commented 9 years ago
Any news on this, I have the same issue.

Original comment by j...@flowpilots.com on 16 Apr 2013 at 1:04

GoogleCodeExporter commented 9 years ago
Haven't heard about a fix yet. For now I have seen this issue on only one
apk (Adobe Reader)

Original comment by cskart...@gmail.com on 17 Apr 2013 at 5:15

GoogleCodeExporter commented 9 years ago
I have this issue on an apk we just built, on Mac OS X 1.8.2 using apktool 
1.5.2 (with smali 1.4.1). 

I tried building the apktool, which includes smali 1.4.2, from source, but the 
tests seem to fail on my machine :(

Any thoughts on how to fix this?

Original comment by j...@flowpilots.com on 17 Apr 2013 at 6:03

GoogleCodeExporter commented 9 years ago
Send me the source of that APK. The problem isn't dex related, so different 
smali(s) won't help at all. The problem comes down to some length that isn't 
being read correctly thus falling out of bounds.

I've been tracing similar problems for weeks in hopes to fix for Apktool 2.0. 
If you'd like to help the problem starts, I believe, at the AXmlResourceParser 
which passes bad values to StringBlock, which fails.

Having the source will allow me to see whats in the /values folder and 
AndroidManifest prior to decompilation, which might speed up the process of 
tracking this down.

Original comment by connor.tumbleson on 17 Apr 2013 at 11:40

GoogleCodeExporter commented 9 years ago
Connor .. I don't have ths source for the APK I am using. I am using some third 
party APK. Jan, do you have source you can provide Connor?

Original comment by cskart...@gmail.com on 18 Apr 2013 at 4:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
apktool 1.5.2 on win8 x64

apktool.jar d "aa.apk"

I: Baksmaling...
testI: Loading resource table...
I: Loaded.
I: Loading resource table from file: H:\Users\Zaxk\apktool\framework\1.apk
I: Loaded.
I: Decoding file-resources...
I: Decoding values*/* XMLs...
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String ind
ex out of range: 4
        at java.lang.String.charAt(Unknown Source)
        at brut.androlib.res.xml.ResXmlEncoders.findNonPositionalSubstitutions(R
esXmlEncoders.java:165)
        at brut.androlib.res.xml.ResXmlEncoders.hasMultipleNonPositionalSubstitu
tions(ResXmlEncoders.java:138)
        at brut.androlib.res.data.value.ResStringValue.serializeExtraXmlAttrs(Re
sStringValue.java:63)
        at brut.androlib.res.data.value.ResScalarValue.serializeToResValuesXml(R
esScalarValue.java:65)
        at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResour
ces.java:264)
        at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:137
)
        at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:93)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:98)
        at brut.apktool.Main.cmdDecode(Main.java:120)
        at brut.apktool.Main.main(Main.java:57)

Original comment by reg...@gmail.com on 5 Oct 2013 at 4:10

GoogleCodeExporter commented 9 years ago
Comment #13 error is not the same as OP error, and is actually probably fixed 
in 2.0. The original OP error is still a valid one.

Original comment by connor.tumbleson on 5 Oct 2013 at 4:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Where can I download 2.0?

Original comment by reg...@gmail.com on 5 Oct 2013 at 4:19

GoogleCodeExporter commented 9 years ago
i have the same issue.and how to use the 2.0? 2.0 seems like a document of jar? 

Original comment by xuwei...@gmail.com on 14 Oct 2013 at 1:02

Attachments:

GoogleCodeExporter commented 9 years ago
i have just tried the 2.0 and found the same issue.

Original comment by xuwei...@gmail.com on 14 Oct 2013 at 1:09

GoogleCodeExporter commented 9 years ago
As would be expected, as this bug report isn't marked as "Fixed".

Original comment by connor.tumbleson on 14 Oct 2013 at 4:02

GoogleCodeExporter commented 9 years ago
I have the same error.
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String 
index out of range: -68
    at java.lang.String.substring(Unknown Source)

I attach apk. I hope this will help you to fix the error.

Original comment by Ineedt...@gmail.com on 14 Dec 2013 at 7:08

Attachments:

GoogleCodeExporter commented 9 years ago
Seems some apk's are abusing a string length miscalculation in apktool.

The problematic function getHTML() of StringBlock.java seems to be the cause. 
Will investigate when more time is present.

Original comment by connor.tumbleson on 19 Dec 2013 at 1:51

GoogleCodeExporter commented 9 years ago
The chinese apk fixed: 
https://github.com/iBotPeaches/Apktool/commit/d90bea10ce33abadc37ec38f1a48f4557c
a568af

The OP issue fixed: 
https://github.com/iBotPeaches/Apktool/commit/ca314b9aaed6a6bac28dbb7d4c7b995728
eaac81

Original comment by connor.tumbleson on 10 Feb 2014 at 2:47