shogo82148 / androidbinary

Android binary file parser written in golang
MIT License
241 stars 79 forks source link

Got panic when parse some apk #9

Closed codeskyblue closed 7 years ago

codeskyblue commented 7 years ago

wandoujia-wandoujia_web.zip

file extension need change from .zip to .apk

When use apk.OpenFile("wandoujia-wandoujia_web.apk") got panic

λ go test -v
=== RUN   TestGetIcon
runtime: VirtualAlloc of 4294967296 bytes failed with errno=1455
fatal error: runtime: cannot map pages in arena address space

runtime stack:
runtime.throw(0x6ee5f7, 0x30)
        C:/Go/src/runtime/panic.go:566 +0x9c
runtime.sysMap(0xc042800000, 0x100000000, 0xb17d01, 0x83f8f8)
        C:/Go/src/runtime/mem_windows.go:116 +0x12c
runtime.(*mheap).sysAlloc(0x824ae0, 0x100000000, 0x81f540)
        C:/Go/src/runtime/malloc.go:407 +0x381
runtime.(*mheap).grow(0x824ae0, 0x80000, 0x0)
        C:/Go/src/runtime/mheap.go:726 +0x69
runtime.(*mheap).allocSpanLocked(0x824ae0, 0x80000, 0x4000)
        C:/Go/src/runtime/mheap.go:630 +0x4f9
runtime.(*mheap).alloc_m(0x824ae0, 0x80000, 0x100000000, 0xb0fe60)
        C:/Go/src/runtime/mheap.go:515 +0xee
runtime.(*mheap).alloc.func1()
        C:/Go/src/runtime/mheap.go:579 +0x52
runtime.systemstack(0xb0fe68)
        C:/Go/src/runtime/asm_amd64.s:314 +0xb5
runtime.(*mheap).alloc(0x824ae0, 0x80000, 0x10100000000, 0x3a)
        C:/Go/src/runtime/mheap.go:580 +0xa7
runtime.largeAlloc(0xfffffffe, 0x910001, 0xc00000003a)
        C:/Go/src/runtime/malloc.go:774 +0x9a
runtime.mallocgc.func1()
        C:/Go/src/runtime/malloc.go:669 +0x45
runtime.systemstack(0xc04201aa00)
        C:/Go/src/runtime/asm_amd64.s:298 +0x7e
runtime.mstart()
        C:/Go/src/runtime/proc.go:1079

goroutine 18 [running]:
runtime.systemstack_switch()
        C:/Go/src/runtime/asm_amd64.s:252 fp=0xc042031660 sp=0xc042031658
runtime.mallocgc(0xfffffffe, 0x67b520, 0x83bd01, 0x674a80)
        C:/Go/src/runtime/malloc.go:670 +0x94b fp=0xc042031700 sp=0xc042031660
runtime.makeslice(0x67b520, 0x7fffffff, 0x7fffffff, 0x0, 0xc042308000, 0x3959)
        C:/Go/src/runtime/slice.go:57 +0x82 fp=0xc042031758 sp=0xc042031700
github.com/shogo82148/androidbinary.readUTF16(0xc04235a0f0, 0xc042308000, 0x3959, 0x0, 0x0)
        D:/GoWorkdir/src/github.com/shogo82148/androidbinary/common.go:159 +0x74 fp=0xc0420317e8 sp=0xc042031758
github.com/shogo82148/androidbinary.readStringPool(0xc04235a0f0, 0xc04235a0f0, 0x8049a0, 0x83bde0)
        D:/GoWorkdir/src/github.com/shogo82148/androidbinary/common.go:134 +0x542 fp=0xc0420318c0 sp=0xc0420317e8
github.com/shogo82148/androidbinary.(*TableFile).readChunk(0xc04237c020, 0x7feea0, 0xc04235a060, 0xc, 0xc04235a0c0, 0xc04237c030, 0x0)
        D:/GoWorkdir/src/github.com/shogo82148/androidbinary/table.go:256 +0x240 fp=0xc042031940 sp=0xc0420318c0
github.com/shogo82148/androidbinary.NewTableFile(0x7fea20, 0xc04235a030, 0xe, 0xc0425c2000, 0x1df504)
        D:/GoWorkdir/src/github.com/shogo82148/androidbinary/table.go:188 +0x1a3 fp=0xc0420319b0 sp=0xc042031940
github.com/shogo82148/androidbinary/apk.(*Apk).parseResources(0xc0420f41c0, 0x0, 0x0)
        D:/GoWorkdir/src/github.com/shogo82148/androidbinary/apk/apk.go:144 +0xe6 fp=0xc042031a30 sp=0xc0420319b0
github.com/shogo82148/androidbinary/apk.OpenZipReader(0x7ff460, 0xc042068090, 0x77e1e9, 0x0, 0x0, 0x0)
        D:/GoWorkdir/src/github.com/shogo82148/androidbinary/apk/apk.go:66 +0x131 fp=0xc042031a80 sp=0xc042031a30
github.com/shogo82148/androidbinary/apk.OpenFile(0x6e449d, 0x10, 0x0, 0x0, 0x0)
        D:/GoWorkdir/src/github.com/shogo82148/androidbinary/apk/apk.go:46 +0x147 fp=0xc042031ac8 sp=0xc042031a80
github.com/shogo82148/androidbinary/apk.TestGetIcon(0xc04207c180)
        D:/GoWorkdir/src/github.com/shogo82148/androidbinary/apk/apk_test.go:10 +0x52 fp=0xc042031f58 sp=0xc042031ac8
testing.tRunner(0xc04207c180, 0x705848)
        C:/Go/src/testing/testing.go:610 +0x88 fp=0xc042031f80 sp=0xc042031f58
runtime.goexit()
        C:/Go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc042031f88 sp=0xc042031f80
created by testing.(*T).Run
        C:/Go/src/testing/testing.go:646 +0x2f3

goroutine 1 [chan receive]:
testing.(*T).Run(0xc04207c0c0, 0x6e26ab, 0xb, 0x705848, 0xc0420bbd10)
        C:/Go/src/testing/testing.go:647 +0x31d
testing.RunTests.func1(0xc04207c0c0)
        C:/Go/src/testing/testing.go:793 +0x74
testing.tRunner(0xc04207c0c0, 0xc0420bbe20)
        C:/Go/src/testing/testing.go:610 +0x88
testing.RunTests(0x705910, 0x817380, 0x1, 0x1, 0x40e0c9)
        C:/Go/src/testing/testing.go:799 +0x320
testing.(*M).Run(0xc0420bbee8, 0xc042045330)
        C:/Go/src/testing/testing.go:743 +0x8c
main.main()
        github.com/shogo82148/androidbinary/apk/_test/_testmain.go:54 +0xcd
exit status 2
FAIL    github.com/shogo82148/androidbinary/apk 1.949s

seems readUTF16 read a too large string

shogo82148 commented 7 years ago

Thank you for your report. I'll check it.

codeskyblue commented 7 years ago

@shogo82148 is there any progress?

shogo82148 commented 7 years ago

I'm working on #10