hsiafan / apk-parser

Apk parser for java
BSD 2-Clause "Simplified" License
1.22k stars 365 forks source link

Don't crash with a buffer underflow when packageCount == 0 #126

Closed paulo-raca closed 4 years ago

paulo-raca commented 4 years ago

This fixes #125

I don't normally see this issue, the particular exception is on com.citymapper.app.release, versionCode 1009500, inside split_kyc2.config.xxxhdpi

AndroidDeveloperLB commented 4 years ago

Wait why does it occur? Did you run the sample app I've put against the APK files I've attached?

How did you find the cause and the fix? Is it now completely fixed?

paulo-raca commented 4 years ago

Did you run the sample app I've put against the APK files I've attached?

Apologies for being dumb, but what sample app? Attached where?

However I did run mvn test

How did you find the cause and the fix? Is it now completely fixed?

I debugged ResourceTableParser.parse() and found that:

Considering there are zero packages, it seemed reasonable to skip reading packageHeader, and it fixes the problem to me.

paulo-raca commented 4 years ago

Oh, the problematic apks.zip attached to #125! I Just tested them, they work fine now :)

AndroidDeveloperLB commented 4 years ago

I see. Can you please check the other issues I've reported, too? Here: https://github.com/hsiafan/apk-parser/issues/99 https://github.com/hsiafan/apk-parser/issues/108 https://github.com/hsiafan/apk-parser/issues/119 https://github.com/hsiafan/apk-parser/issues/122 https://github.com/hsiafan/apk-parser/issues/123

AndroidDeveloperLB commented 4 years ago

I don't see a crash on split_kyc2.config.xxxhdpi . Attached here:

split_kyc2.config.xxxhdpi.apk.zip

Can you make a sample to show that it crashes, using the official repository?