aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar
diff options
context:
space:
mode:
authorGravatar cushon <cushon@google.com>2018-02-12 08:28:15 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-12 08:29:43 -0800
commit584f9dffbad34a0f86bd1bc9c5cd9dbbbaa25146 (patch)
tree2d24af8c5356b2a80a402ca8856f8828f0133b7a /third_party/ijar
parent33ca88f7a757d9c5c103e539fd097abdd613b037 (diff)
Use a different date time when normalizing zip entries
PiperOrigin-RevId: 185381597
Diffstat (limited to 'third_party/ijar')
-rw-r--r--third_party/ijar/test/IjarTests.java6
-rwxr-xr-xthird_party/ijar/test/ijar_test.sh2
-rw-r--r--third_party/ijar/zip.cc9
3 files changed, 9 insertions, 8 deletions
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<uint32_t>::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