AlexeySoshin / smali2java

Recreate Java code from Smali
486 stars 84 forks source link

CRASH: On run against smali #23

Closed Hu1buerger closed 2 years ago

Hu1buerger commented 3 years ago

When running smali2java against a known good smali file (output from android studio) the tool crashes.

panic: runtime error: slice bounds out of range [:-1]

goroutine 1 [running]:
github.com/alexeysoshin/smali2java/parser.(*MethodParser).Parse(0xc0000b1828, 0xc0000b18d0, 0xc000374b40, 0x5, 0x5, 0x4c, 0xc0004398f8)
    xxx/smali2java/parser/method.go:84 +0x1032
github.com/alexeysoshin/smali2java/parser.(*JavaFile).ParseLine(0xc0000b18d0, 0xc000357360, 0x4b, 0xc000357360, 0x4b)
    xxx/smali2java/parser/java_file.go:117 +0x9f3
main.convertSmali(0xc000351380, 0x31, 0xc0000b6004)
    xxx/smali2java/smali2java.go:70 +0x254
main.parseSmaliFiles.func1(0xc000351380, 0x31, 0x1115878, 0xc00009b2b0, 0x0, 0x0, 0xc0003513c0, 0xc0000b1ad0)
    xxx/smali2java/smali2java.go:40 +0x193
path/filepath.walk(0xc000351380, 0x31, 0x1115878, 0xc00009b2b0, 0xc0000b1f10, 0x0, 0x0)
    /usr/local/Cellar/go/1.16.6/libexec/src/path/filepath/path.go:414 +0x457
path/filepath.walk(0xc00036f9a0, 0x1b, 0x1115878, 0xc0002bb6c0, 0xc0000b1f10, 0x0, 0x0)
    /usr/local/Cellar/go/1.16.6/libexec/src/path/filepath/path.go:438 +0x31b
path/filepath.walk(0xc00038df20, 0x13, 0x1115878, 0xc0002bb860, 0xc0000b1f10, 0x0, 0x0)
    /usr/local/Cellar/go/1.16.6/libexec/src/path/filepath/path.go:438 +0x31b
path/filepath.walk(0xc0001ccce0, 0xc, 0x1115878, 0xc0002bb5f0, 0xc0000b1f10, 0x0, 0x0)
    /usr/local/Cellar/go/1.16.6/libexec/src/path/filepath/path.go:438 +0x31b
path/filepath.walk(0x7ffeefbffc58, 0x4, 0x1115878, 0xc00009aa90, 0xc0000b1f10, 0x0, 0xc)
    /usr/local/Cellar/go/1.16.6/libexec/src/path/filepath/path.go:438 +0x31b
path/filepath.Walk(0x7ffeefbffc58, 0x4, 0xc0000b1f10, 0x10ba8a5, 0xc0000bc120)
    /usr/local/Cellar/go/1.16.6/libexec/src/path/filepath/path.go:501 +0x113
main.parseSmaliFiles(0x7ffeefbffc58, 0x4)
    xxx/mali2java/smali2java.go:29 +0x76
main.main()
    xxx/smali2java/smali2java.go:23 +0xe8

Unfortunately I don't write go and am unfamiliar with debugging go. Otherwise I would have added some info on what file and method the tool panics.

Will update if I know more.

Hu1buerger commented 3 years ago

See [https://github.com/Hu1buerger/smali2java/commit/2e46bc8100059dbbbd4389cf5993b3ede4a4e473]()

The causing smali method

.method protected varargs abstract b([Ljava/lang/Object;)Ljava/lang/Object;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "([TParams;)TResult;"
        }
    .end annotation
.end method

In androidx.loader.content.ModernAsyncTask