History log of /libcore/luni/src/main/java/java/util/zip/ZipEntry.java
Revision Date Author Comments
6b37f0bb40c3789833a9fd02c321d68354c6ecaf 31-Jul-2015 Narayan Kamath <narayan@google.com> Fix broken Zip64 extended info size checks.

We assumed that all fields listed in the extended info layout were
always present. This is not the case. Only the size / uncompressed
size are required fields (in the LFH) and the directory offset is
required only if the corresponding field in the regular record is
0xFFFFFFFF. The same goes for disk number too, but we don't support
spanned archives, so we can assume that it's never present.

This change also fixes a spec violation where we were *not* writing
0xFFFFFFFF to the central directories LFH offset field when we were
putting the actual information in the Zip64 Extended info field.

This change also adds lower level unit tests to some of the Zip64
parsing functions since it's pretty hard (impossible ?) to find a
Zip64 tool that outputs stuff in the format we want.

bug: 22851464

(cherry picked from commit 837aeb356c331960073e5ddbf449779c6194f164)

Change-Id: I031b3151b7deeda8a0a98acfba3f5a906c0c360c
a50a2ffbd82c953aa3a1d832e311ed8c869f454e 27-Feb-2015 Narayan Kamath <narayan@google.com> Remove size check that was accidentally removed.

We can now accept sizes larger than 4GB, but negative
sizes should still be rejected.

Fixes harmony test ZipEntryTest#test_setSizeJ.

Change-Id: Ie226daecb378ae5627b404dba926d53143ec7774
12f5c69e074d6ef012706068416f0a61b70b4e52 27-Jan-2015 Narayan Kamath <narayan@google.com> Implement zip64 support for ZipFile/ZipInputStream/ZipOutputStream.

There are several open questions that I hope to resolve in future
changes :

- Our heuristics for detecting whether a zip outputstream should
switch over to zip64 or not are imprecise.

- Also, given that we now officially support zip64, we have to assume
new entries whose size is unknown need the zip64 header / footer.
This will make output files slightly larger and less compatible with
older tools. If we don't do this, we'll have to go back and rewrite &
compact parts of the stream we'd already flushed, which isn't always
possible. The other option is to assume zip32 for streams of unknown
length and throw if more than 4G of data is written to them.

Change-Id: Ibb4a97b5f83fd3ab850d7c407ecfda663968a6b9
f6f506cef650471dbe9dc380e8fdefb560ad0274 08-Jan-2015 Narayan Kamath <narayan@google.com> Add a warning about relative paths to ZipEntry#getName.

bug: 18644314
Change-Id: I62e94208392a5f22130ff603bfd1f2f9ec9ef81d
8c585e912ae4fd7b0b6f5a2e2ddabed6c70289cf 07-Aug-2014 Piotr Jastrzebski <haaawk@google.com> Remove nameLength field from ZipEntry.

It seems that this field is never used outside the internal constructor so it
can be a local variable instead.

Change-Id: I2aa26fb3fd13c571224a9aee14c7eea93e5c9591
c48199457bc0ed96404414ba4d4ad15e4f0fd6bb 07-Aug-2014 Narayan Kamath <narayan@google.com> Revert "Remove nameLength field from ZipEntry."

This reverts commit c4da34ca5792e0c73577f868249fdfe8a11a01f6.

Change-Id: I1b93ecfcb8a867a670af717eb25c7076b7097d5c
c4da34ca5792e0c73577f868249fdfe8a11a01f6 07-Aug-2014 Piotr Jastrzebski <haaawk@google.com> Remove nameLength field from ZipEntry.

It seems that this field is never used outside the internal constructor so it
can be a local variable instead.

Change-Id: Icd9e009a24ae22da8f5dfd18b9f0ab80913129d4
e3d756c5dae1af2aa5f0ad8bc7f133df3e7401eb 11-Mar-2014 Neil Fuller <nfuller@google.com> Add Java 1.7 APIs: ZipFile, ZipInputStream, ZipOutputStream

Add constructor support for the character encoding to use.

When reading a ZipFile this is used for the file comment and for
entry names and comments when a zip entry is not self-described
as UTF-8 encoded.

When writing a zip file the character encoding determines the
encoding used for the file comment, entry names and comments.

The default for reading and writing when the character encoding
is not specified remains as UTF-8.

Additional fix:
ZipOutputStream: null comments no longer cause NullPointerException.

Change-Id: I7cadfa939377d0f87fd5503dae2a0b2dbac2ba39
0c1869ed7f46baf764f9daf4e64c77cd7fbd3516 29-Nov-2013 Narayan Kamath <narayan@google.com> Add a JNI wrapper over libziparchive.

All functions delegate directly to the native code. We
do not perform any sort of central directory or local file
related lookups in the java layer.

For each entry, libziparchive gives us an offset to the start
of data for the entry and the compressed size. We use a
RandomAccessFile to seek to that offset and then construct an
InputStream that's bounded between [offset, offset + compressed_size).

We reuse existing code (JarVerifier / Manifest) for certificate
validation & collection.

bug: 10193060

Change-Id: I21eb4e6dc6aa8749e3f63830f9799e1f621d26e6
3d2b2ad2cd1f05ba72a550082083da4b5898f30b 11-Sep-2013 Kenny Root <kroot@google.com> Revert "Revert "Reconcile differences between zip implementations""

This reverts commit c2bcd6f029fa02657889af1120f2eaaf73da968e.

Bug: 10424836
Change-Id: I63f801c4f451383bfadd9c76f99c3ebb2726e7b0
c2bcd6f029fa02657889af1120f2eaaf73da968e 11-Sep-2013 Kenny Root <kroot@google.com> Revert "Reconcile differences between zip implementations"

This reverts commit bb68396d3c4262760055101cbf18c80999c692f5.

Change-Id: I56daf02fe24cc592844a5d0a9f1ca7432da2293e
bb68396d3c4262760055101cbf18c80999c692f5 21-Aug-2013 Kenny Root <kroot@google.com> Reconcile differences between zip implementations

Reconcile the difference between ZipFileRO and java.util.ZipFile to have
the same behavior.

Bug: 10424836
Change-Id: I6dcbb5234142dc8574052be2b18f062ef2e93b02
613ebea3da2d973bbe6496d6e57eb4c8d75b148e 21-Aug-2013 Kenny Root <kroot@google.com> Fix extra and comment ordering in ZipEntry reading

(cherry picked from commit c242577b1569f97f806ef176e4549141df147b78)

Bug: 10424836
Change-Id: I99e6722ef898baa7f9a2d56e84e88aae5a6c9f4a
c242577b1569f97f806ef176e4549141df147b78 21-Aug-2013 Kenny Root <kroot@google.com> Fix extra and comment ordering in ZipEntry reading

Change-Id: I99e6722ef898baa7f9a2d56e84e88aae5a6c9f4a
44e8930b48015aacbad027c5a8d9a4c7e00e329e 06-Aug-2013 Elliott Hughes <enh@google.com> Bumper ZipFile/ZipEntry backport.

Bug: https://code.google.com/p/android/issues/detail?id=58465
Bug: 8219321
Bug: 8476102
Bug: 8617715
Bug: 9695860
Bug: 9950697
Bug: 10148349
Bug: 10227498
Change-Id: I94c3e9664a429c94c336115618a46283a13996e0
8405b26225d88812bb336b2b6c0181266768c3f0 06-Aug-2013 Elliott Hughes <enh@google.com> Disallow filenames containing NUL bytes.

C code gets confused by such filenames, and even if we can handle them,
they're a misleading and of questionable utility because a valid pathname
can't contain a NUL byte.

Bug: https://code.google.com/p/android/issues/detail?id=58465
Bug: 10148349
Change-Id: I3f7e1a17c526b6bb5752dae82610125ad2648d54
(cherry picked from commit b1d05573ae20cdd3d5b4e25f905ce44c8f7d5c0e)
b1d05573ae20cdd3d5b4e25f905ce44c8f7d5c0e 06-Aug-2013 Elliott Hughes <enh@google.com> Disallow filenames containing NUL bytes.

C code gets confused by such filenames, and even if we can handle them,
they're a misleading and of questionable utility because a valid pathname
can't contain a NUL byte.

Bug: https://code.google.com/p/android/issues/detail?id=58465
Bug: 10148349
Change-Id: I3f7e1a17c526b6bb5752dae82610125ad2648d54
339f18ff18ea0c13fae1d6750ffe8eaf847e62e9 04-Jul-2013 Elliott Hughes <enh@google.com> Values in ZIP files are unsigned.

Bug: 9695860

(cherry picked from commit 9edf43dfcc35c761d97eb9156ac4254152ddbc55)

Change-Id: Ic14eac58fdcfc343a9e23df8c26ba0dd24c9e189
fe39951ed36353002263aefef7963a8c8b9c6441 04-Jul-2013 Elliott Hughes <enh@google.com> Values in ZIP files are unsigned.

Bug: 9695860
Change-Id: I5c12dc5f3c70a9fe081adf5bf5b6b4b3a115e7e1
(cherry picked from commit 9edf43dfcc35c761d97eb9156ac4254152ddbc55)
7f649edc647081ac299742607d7c497486ff41a7 04-Jul-2013 Elliott Hughes <enh@google.com> Values in ZIP files are unsigned.

Bug: 9695860

(cherry picked from commit 9edf43dfcc35c761d97eb9156ac4254152ddbc55)

Change-Id: Ic14eac58fdcfc343a9e23df8c26ba0dd24c9e189
9edf43dfcc35c761d97eb9156ac4254152ddbc55 04-Jul-2013 Elliott Hughes <enh@google.com> Values in ZIP files are unsigned.

Bug: 9695860
Change-Id: I5c12dc5f3c70a9fe081adf5bf5b6b4b3a115e7e1
2a6f23ff8690ac2f025588a360547ce96cde0943 29-Jun-2013 Elliott Hughes <enh@google.com> Add java.nio.charsets.StandardCharsets.

Bug: 3484927
Change-Id: I5820267491b850b8fcc696fa48962710de123009
25681be69e19a834b00cfbf54cd99ac13f12b9ff 17-Apr-2013 William Luh <williamluh@google.com> Only enforce the encrypted bit in the GPBF, and ignore other unsupported bits.

(cherry-pick of 7a302a49a7c8b99e2f34fff660e199fb7c776bc1.)

Bug: 8617715
Change-Id: Ibfe919d67fd17cee050d23811faa5aa64116dfb4
941d18fe01a8b2b69c67a006d1f3d855bdccde95 17-Apr-2013 William Luh <williamluh@google.com> Only enforce the encrypted bit in the GPBF, and ignore other unsupported bits.

Bug: 8617715
Change-Id: I2f906ae6107d2bdf990a7991f56d4a0873bca634
7a302a49a7c8b99e2f34fff660e199fb7c776bc1 17-Apr-2013 William Luh <williamluh@google.com> Only enforce the encrypted bit in the GPBF, and ignore other unsupported bits.

Bug: 8617715
Change-Id: I2f906ae6107d2bdf990a7991f56d4a0873bca634
6aed748da1deaa820d574446037401893d73be9b 02-Apr-2013 William Luh <williamluh@google.com> Don't install APK files with unsupported General Purpose Bit Flag bits.

Bug: 8476102

(cherry picked from commit d0bd4c19678429b19ac4b9c7477b28241d5dd1db)

Change-Id: I03f19095ac4e6f8abcb61ba6c120227c2df1f2d1
d0bd4c19678429b19ac4b9c7477b28241d5dd1db 02-Apr-2013 William Luh <williamluh@google.com> Don't install APK files with unsupported General Purpose Bit Flag bits.

Bug: 8476102
Change-Id: I764c2aec944558129c8ac04ee0593fb3de82870e
63694641ecf9f473d0a3b34b8377a94440990857 10-Dec-2012 Elliott Hughes <enh@google.com> Fix formatting of a doc comment for ZipEntry.setComment.

Change-Id: I577c960ea0f486d1b1d55a0d31ce2c71e3776426
f05aeedc00c8e7ab7650067ce1dc301547a3914b 10-Dec-2012 Elliott Hughes <enh@google.com> More java.util.zip documentation improvements.

Change-Id: I8ebc23b8a7a7affee0fd3756c3861cf5b6c07ee4
13f30b9167639ad63da1707102db6320e8f76474 08-Dec-2012 Elliott Hughes <enh@google.com> Clean up ZipFile a little, fix a few bugs, and improve the documentation.

The main bug fixed is fixing support for .zip files larger than 2GiB (where
the central directory offset's top bit is set).

We were checking character counts rather than byte counts in several places
too, which could lead to corrupt zip files.

I've also added a comment to readCentralDirectory because I keep coming back
to this code, wanting to make it lazy, and never remember (until I've done
half the work) why that's not possible.

I've also clarified a lot of the documentation.

Bug: http://code.google.com/p/android/issues/detail?id=36187
Change-Id: Iaa8eadc501ead7c70528bd9063d5893a325dcea1
cff1616012dc0d56c2da9af2b9b1183e76c7e044 04-Dec-2012 Elliott Hughes <enh@google.com> Add detail messages to all the easy IllegalArgumentException cases.

Noticed during my recent Matcher change.

Change-Id: I415d911b26d0ee548ca04d56bba7fc3d4e6b3f88
d43b9ef11a1095967a3396b246639b563e1a4128 12-Sep-2012 Kenny Root <kroot@google.com> Add consistent reasons for NullPointerException

Semi-automated replacement of empty and non-conforming
NullPointerException reason messages.

(cherry-pick of 86acc043d3334651ee26c65467d78d6cefedd397.)

Change-Id: I6d893979f5c20a50e841e32af9fd7b2d8bc9d54d
86acc043d3334651ee26c65467d78d6cefedd397 12-Sep-2012 Kenny Root <kroot@google.com> Add consistent reasons for NullPointerException

Semi-automated replacement of empty and non-conforming
NullPointerException reason messages.

Change-Id: Iedeb4b21949e973c4042ce5982dda315f2e785e1
6186821cb13f4ac7ff50950c813394367e021eae 08-Feb-2011 Jesse Wilson <jessewilson@google.com> Move libcore.base classes to libcore.util and libcore.io.

Change-Id: I2340a9dbad3561fa681a8ab47d4f406e72c913e3
e43b3f6c7b343f4b6c738120a2ac2f93c5bd9a8e 10-Nov-2010 Elliott Hughes <enh@google.com> Fix a bug I introduced, and do more zip cleanup.

This code's quite hairy in its use of int/long. I can't just change the fields
to int because they seem to use -1L to mean "unset" while still allowing the
whole int range of values (including -1). We'll have to look at the zip
specification to see whether that's right, but for now, let's just avoid sign
extension.

I've also cleaned up some of the other code, most notably throwing more
detailed exception messages where it's easy, and removing hand-made readFully
implementations.

Bug: 3181430
Change-Id: I382568a8975c9b8b2ee5b344817134472369d308
b5bde2fd72189192b52e726a2d606d70c3c8a34b 02-Nov-2010 Elliott Hughes <enh@google.com> More shift removal.

A few more customers for OSMemory's peek/poke abilities, and a bunch of shifts
that should have been multiplications.

Bug: 3032515
Change-Id: Ic518fd8f7565d67523ea10e3f5afca3a9c8501b8
739493443ce2ea5b0a92dd1725a4ed630db7b27b 23-Sep-2010 Elliott Hughes <enh@google.com> Simplify the ZipFile implementation, removing unbuffered I/O.

Bug: 3018772
Change-Id: I183e9ac597f9483418b0b337fc9e3944d473f359
c0c98ee1c95fd3b19646b4cb9771abf98a045ef0 23-Sep-2010 Elliott Hughes <enh@google.com> Remove unbuffered single-byte I/O from ZipFile.

This is enough to fool my current checking (and a little bit better than the
existing code), but I do plan on better checking and a rewrite of ZipFile.

Bug: 3018772
Change-Id: I607fee807c2bcbe9d59b883ef7bfbaa9a8f54ea8
355a98498e4bc434dde8809eacf6e150f9b25f89 02-Sep-2010 Jesse Wilson <jessewilson@google.com> Fix a findbugs bug where ZipEntry.clone() didn't call super.clone().

See http://b/2099615

Change-Id: Ib1347aa5e35c62501d9d59eccfdfed098559d552
e810d3b49631329b11440aa5b7a54db181d42ed1 15-Jun-2010 Elliott Hughes <enh@google.com> More charset-related cleanup/optimization.

This patch adds a Charsets class that lets us avoid a hash lookup and an extra
level of method call indirection when calling String.getBytes or "new String"
for a well-known guaranteed charset. It also fixes callers to take advantage.

This also adds a special case to "new String" for the UTF-8 charset to avoid
needless duplication if we guessed the correct buffer size (which we will for
input that happens to be US-ASCII too).

The ModifiedUtf8 class gives a more meaningful name for Utils.convertUTF8WithBuf.

This also removes a dead link and un-tinyurl'ed another.

Change-Id: I02712f53dee16feb3b1db2c14536dc055126cd04
cec4dd4b1d33f78997603d0f89c0d0e56e64dbcd 26-Apr-2010 Peter Hallam <peterhal@google.com> merge more modules into luni