-
Notifications
You must be signed in to change notification settings - Fork 18k
archive/zip: ignore malformed Extra field #13166
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
Comments
Can you ask "dex protector" to fix their zip code, if they're producing non-compliant zip files? (the fact that both Go and later PHP releases reject it is interesting, suggesting that the problem isn't with Go) |
Mmm Brad can you help me :). |
No, sorry, I can't help you quickly. I don't have time right now to investigate and fully understand this bug report on short notice, especially because it sounds like the answer is that the zip file is just invalid. |
:( ok, thx |
Please provide a reference to your bug report for dex protector. |
I was thinking. |
Where is your dex protector bug report? I don't want to consider fixing this here until the creator of the problem has already considered fixing it there. Also, I would need an example of such a corrupt zip. |
The extra field contains these bytes:
That's obviously wrong, since it's supposed to contain a sequence of entries each beginning with a 2-byte tag + 2-byte size. Maybe dexprotector even does this intentionally, to make some analysis tools reject the zip file. However, this is something that was added late to zip files, and early versions of the tools are expected to ignore the extra fields, and most do. The only reason we parse the extra fields is to look for the zip64 extension. Obviously it's not present in this file, so I think rather than return ErrFormat we should just stop looking and keep going. This is the second time we've had problems with our extra field parsing being too strict. Let's just make it best effort and be done with it. It's clearly something zip implementations disagree about. |
+1 |
CL https://golang.org/cl/18317 mentions this issue. |
I have problem with golang zip reader. We have apk builder which build apk and then encrypted this apk with dex protector.
When i try to open apk file, go return err "zip: not a valid zip file". But when i try to open with unzip or zipinfo, worked fine.
(Also I noticed something interesting: in php 5.5 apk file opened with ZipArchive fine, but in 5.6 return error like golang)
I try open to debug golang archive/zip pckage and found that error returned in this line https://github.com/golang/go/blob/master/src/archive/zip/reader.go#L269.
Then i try to debug this line like this:
And have this results:
Problem in extra headers (i think this extra headers add dex protector when encrypt apk). Size more then length of extra bytes. But unzip util and ZipArchive in php5.5 woked perfect with this extras. How to fix this ?
I want to rewrite this piece in go archive/zip package, so that the extras do not interfere golang zip reader.
It's very important for me, because i rewrite build apk from php to golang and I came across a problem that can not decide :(. Please help me.
The text was updated successfully, but these errors were encountered: