From 584f9dffbad34a0f86bd1bc9c5cd9dbbbaa25146 Mon Sep 17 00:00:00 2001 From: cushon Date: Mon, 12 Feb 2018 08:28:15 -0800 Subject: Use a different date time when normalizing zip entries PiperOrigin-RevId: 185381597 --- third_party/ijar/test/IjarTests.java | 6 +++--- third_party/ijar/test/ijar_test.sh | 2 +- third_party/ijar/zip.cc | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'third_party/ijar') diff --git a/third_party/ijar/test/IjarTests.java b/third_party/ijar/test/IjarTests.java index 467680552b..a2e10db570 100644 --- a/third_party/ijar/test/IjarTests.java +++ b/third_party/ijar/test/IjarTests.java @@ -23,11 +23,11 @@ import com.google.common.io.ByteStreams; import com.google.devtools.build.java.bazel.BazelJavaCompiler; import java.io.File; import java.io.IOException; -import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; -import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -289,7 +289,7 @@ public class IjarTests { assertThat(attributes.getValue("Injecting-Rule-Kind")).isEqualTo("foo_library"); assertThat(jf.getEntry(JarFile.MANIFEST_NAME).getLastModifiedTime().toInstant()) .isEqualTo( - Instant.ofEpochMilli(new GregorianCalendar(1980, 0, 1, 0, 0, 0).getTimeInMillis())); + LocalDateTime.of(2010, 1, 1, 0, 0, 0).atZone(ZoneOffset.systemDefault()).toInstant()); } } } diff --git a/third_party/ijar/test/ijar_test.sh b/third_party/ijar/test/ijar_test.sh index eacf6e42bb..1a4959da24 100755 --- a/third_party/ijar/test/ijar_test.sh +++ b/third_party/ijar/test/ijar_test.sh @@ -230,7 +230,7 @@ function test_ijar_output() { # Check that -interface.jar timestamps are normalized: check_eq 0 $(TZ=UTC $JAR tvf $A_INTERFACE_JAR | - grep -v 'Tue Jan 01 00:00:00 UTC 1980' | wc -l) \ + grep -v 'Fri Jan 01 00:00:00 UTC 2010' | wc -l) \ "Interface jar contained non-zero timestamps!" diff --git a/third_party/ijar/zip.cc b/third_party/ijar/zip.cc index 957407bece..c5ff929836 100644 --- a/third_party/ijar/zip.cc +++ b/third_party/ijar/zip.cc @@ -73,7 +73,8 @@ namespace devtools_ijar { // http://www.info-zip.org/FAQ.html#limits static const u8 kMaximumOutputSize = std::numeric_limits::max(); -static const u4 kDosEpoch = 1 << 21 | 1 << 16; // January 1, 1980 in DOS time +static const u4 kDefaultTimestamp = + 30 << 25 | 1 << 21 | 1 << 16; // January 1, 2010 in DOS time // // A class representing a ZipFile for reading. Its public API is exposed @@ -873,7 +874,7 @@ int OutputZipFile::WriteEmptyFile(const char *filename) { put_u2le(q, 10); // extract_version put_u2le(q, 0); // general_purpose_bit_flag put_u2le(q, 0); // compression_method - put_u4le(q, kDosEpoch); // last_mod_file date and time + put_u4le(q, kDefaultTimestamp); // last_mod_file date and time put_u4le(q, entry->crc32); // crc32 put_u4le(q, 0); // compressed_size put_u4le(q, 0); // uncompressed_size @@ -904,7 +905,7 @@ void OutputZipFile::WriteCentralDirectory() { put_u2le(q, ZIP_VERSION_TO_EXTRACT); // version to extract put_u2le(q, 0); // general purpose bit flag put_u2le(q, entry->compression_method); // compression method: - put_u4le(q, kDosEpoch); // last_mod_file date and time + put_u4le(q, kDefaultTimestamp); // last_mod_file date and time put_u4le(q, entry->crc32); // crc32 put_u4le(q, entry->compressed_length); // compressed_size put_u4le(q, entry->uncompressed_length); // uncompressed_size @@ -995,7 +996,7 @@ u1* OutputZipFile::WriteLocalFileHeader(const char* filename, const u4 attr) { put_u2le(q, 0); // general purpose bit flag u1 *header_ptr = q; put_u2le(q, COMPRESSION_METHOD_STORED); // compression method = placeholder - put_u4le(q, kDosEpoch); // last_mod_file date and time + put_u4le(q, kDefaultTimestamp); // last_mod_file date and time put_u4le(q, entry->crc32); // crc32 put_u4le(q, 0); // compressed_size = placeholder put_u4le(q, 0); // uncompressed_size = placeholder -- cgit v1.2.3