From 0e99a2f79ae3831d8bb749e470b3d3217083b015 Mon Sep 17 00:00:00 2001 From: beonit Date: Sat, 18 Jul 2015 02:08:16 +0900 Subject: [PATCH] libziparchive: fix calculation of mod_time. Take mod_date into account as well, and fixes the issue where all entries had creation dates in 1979. Signed-off-by: beonit Change-Id: Id101794fa08218d15f2d1ba4e4a313c1807ea7aa --- libziparchive/zip_archive.cc | 2 +- libziparchive/zip_archive_test.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc index f1e13a7bc..3d18f7c67 100644 --- a/libziparchive/zip_archive.cc +++ b/libziparchive/zip_archive.cc @@ -588,7 +588,7 @@ static int32_t FindEntry(const ZipArchive* archive, const int ent, // and other interesting attributes from the central directory. These // will later be compared against values from the local file header. data->method = cdr->compression_method; - data->mod_time = cdr->last_mod_time; + data->mod_time = cdr->last_mod_date << 16 | cdr->last_mod_time; data->crc32 = cdr->crc32; data->compressed_length = cdr->compressed_size; data->uncompressed_length = cdr->uncompressed_size; diff --git a/libziparchive/zip_archive_test.cc b/libziparchive/zip_archive_test.cc index 9a3cdb434..32b1a38b1 100644 --- a/libziparchive/zip_archive_test.cc +++ b/libziparchive/zip_archive_test.cc @@ -272,6 +272,7 @@ TEST(ziparchive, FindEntry) { ASSERT_EQ(static_cast(17), data.uncompressed_length); ASSERT_EQ(static_cast(13), data.compressed_length); ASSERT_EQ(0x950821c5, data.crc32); + ASSERT_EQ(static_cast(0x438a8005), data.mod_time); // An entry that doesn't exist. Should be a negative return code. ZipString absent_name;