summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kelvin Zhang <zhangkelvin@google.com> 2020-08-07 18:20:15 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2020-08-07 18:20:15 +0000
commit49023a992f6753670406d00c1036f015cbaf645e (patch)
tree796274b976798a6bbfd7a462b605e1f617fff224
parent9f381d5ce3b670b07db8800b1bc6beca26b32393 (diff)
parent45e2f1405dcae0498c35b780717256dc619e4e05 (diff)
Merge "Fix zip64 reader when file size is < 4GB and 32 bit fields are -1"
-rw-r--r--third_party/zip/android.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/third_party/zip/android.go b/third_party/zip/android.go
index 8d387ccb1..f8e45c56d 100644
--- a/third_party/zip/android.go
+++ b/third_party/zip/android.go
@@ -43,6 +43,15 @@ func (w *Writer) CopyFrom(orig *File, newName string) error {
offset: uint64(w.cw.count),
}
w.dir = append(w.dir, h)
+ if !fh.isZip64() {
+ // Some writers will generate 64 bit sizes and set 32 bit fields to
+ // uint32max even if the actual size fits in 32 bit. So we should
+ // make sure CompressedSize contains the correct value in such
+ // cases. With out the two lines below we would be writing invalid(-1)
+ // sizes in such case.
+ fh.CompressedSize = uint32(fh.CompressedSize64)
+ fh.UncompressedSize = uint32(fh.UncompressedSize64)
+ }
if err := writeHeader(w.cw, fh); err != nil {
return err