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

Crash with a smali file declaring varargs abstract method #21

Open
vricosti opened this issue May 9, 2021 · 3 comments
Open

Crash with a smali file declaring varargs abstract method #21

vricosti opened this issue May 9, 2021 · 3 comments

Comments

@vricosti
Copy link

vricosti commented May 9, 2021

Hi,

I was curious to test smali2java on a dissasembled apk but I have an exception:
`Found cso.smali
panic: runtime error: slice bounds out of range [:-1]

goroutine 1 [running]:
github.com/alexeysoshin/smali2java/parser.(*MethodParser).Parse(0xc0003a9810, 0xc0003a9a40, 0xc00012f630, 0x5, 0x5, 0x0, 0x0)
c:/Apps/ReverseEngineering/smali2java/parser/method.go:84 +0x206f
github.com/alexeysoshin/smali2java/parser.(*JavaFile).ParseLine(0xc0003a9a40, 0xc000147170, 0x2a, 0x0, 0x0)
c:/Apps/ReverseEngineering/smali2java/parser/java_file.go:117 +0x179e`

cso.smali.txt

The problem is with the following lines:

.method public varargs abstract g([Lntb;)V .end method

Inside MethodParser.Parse the variable smaliMethod holds the strings "abstract" so the search for () fails and argumentsIndex/returnValueIndex are -1.

splitLine
badindex

Update:

I have added the following lines to fix it:

if currentLine[methodNameIndex] == java.Abstract { staticOrAbstract = java.Abstract methodNameIndex++ }

@vricosti
Copy link
Author

vricosti commented May 9, 2021

From what I understand you don't keep track of what you have already parsed, so your tool could be a lot improved if you build an abtrasct syntax tree (ast) and it would allow to decode more smali.

@AlexeySoshin
Copy link
Owner

Thank you for the detailed report.

I'm happy to accept the PR with this fix, or alternatively, I can add this fix myself in another week or two.

@daren-k
Copy link

daren-k commented Oct 5, 2021

Hi @vricosti @AlexeySoshin,

I run it to the same issues it this fix on a PR or was already promote to the master??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants