iyxan23 / zipalign-java

zipalign implemented as a java library with 0 deps
MIT License
53 stars 13 forks source link

Cannot handle apk file size > 2G #12

Open crackleeeessyp opened 1 month ago

crackleeeessyp commented 1 month ago

Seems the centralDirOffset is wrong if apk file size > 2G

image

iyxan23 commented 1 month ago

thanks for reporting!

it looks like I missed that those fields are unsigned, and ByteBuffer is treating them as signed ints, which isn't right. I also did a quick search and found that ByteBuffer doesn't support reading unsigned ints directly. So, we'll need to create our own way to handle this, maybe by extending the ByteBuffer class.

but sorry, I can't dive into this right now as I'm pretty swamped. I'll take a look next month. If anyone else wants to give it a shot in the meantime, feel free! :)

crackleeeessyp commented 1 month ago

@iyxan23 , thanks for your quick response!

Are there any document I can refer for zip format, and if time available, I will try to fix it.

By the way, does APK support zip64? If it also supports zip64, I think we should also consider it

iyxan23 commented 1 month ago

hi @crackleeeessyp

Are there any document I can refer for zip format, and if time available, I will try to fix it.

thanks for the helping hand, I really appreciate it! here are some of the sources I used:

https://github.com/iyxan23/zipalign-java/blob/ea2e0df8e9ee3e3f43cbdb70b7a5f5f0effc59c8/src/main/java/com/iyxan23/zipalignjava/ZipAlign.java#L484-L486

By the way, does APK support zip64? If it also supports zip64, I think we should also consider it

actually, that's the one thing that I have been wondering about whilst developing zipalign-java!

I haven't implemented it yet, and I don't think there are APKs out there that uses zip64, looking at this stackoverflow question. And also, I've seen several phones that flat-out throws an error "zip64 not supported" when users tries to install a zip64 apk (but interestingly, they exist?)

I'm honestly not sure whether or not zip64 should be implemented; if you wanted to do it, I'm all ears :)