diff options
author | 2016-04-06 15:33:03 -0700 | |
---|---|---|
committer | 2016-04-28 12:13:16 +0000 | |
commit | 1ead474f61fb3fe7d77ccdd8e65037fb8c93ad6d (patch) | |
tree | a21478316f777b9fb134798a12c962a28dfd265a /include/androidfw/ZipUtils.h | |
parent | 4dd00e93f300a50097c1ec09ca291849830e98dc (diff) |
ZipUtils: Fix wrong timestamps when getEntryInfo
"tm_mon" format should align with "ZipEntry::setModWhen" in aapt.
"tm_isdst" should be initialized, or it will because random value
and cause error in function mktime().
BUG:28021145
Change-Id: I1e8d5c14e5d7b875bf9cd940cb7f4c5b93a1bcd6
Diffstat (limited to 'include/androidfw/ZipUtils.h')
-rw-r--r-- | include/androidfw/ZipUtils.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/androidfw/ZipUtils.h b/include/androidfw/ZipUtils.h index 094eaa8dd214..55575d774522 100644 --- a/include/androidfw/ZipUtils.h +++ b/include/androidfw/ZipUtils.h @@ -21,6 +21,7 @@ #define __LIBS_ZIPUTILS_H #include <stdint.h> +#include <string.h> #include <stdio.h> #include <time.h> @@ -63,16 +64,21 @@ public: /* * Utility function to convert ZIP's time format to a timespec struct. + * + * NOTE: this method will clear all existing state from |timespec|. */ static inline void zipTimeToTimespec(uint32_t when, struct tm* timespec) { const uint32_t date = when >> 16; + + memset(timespec, 0, sizeof(struct tm)); timespec->tm_year = ((date >> 9) & 0x7F) + 80; // Zip is years since 1980 - timespec->tm_mon = (date >> 5) & 0x0F; + timespec->tm_mon = ((date >> 5) & 0x0F) - 1; timespec->tm_mday = date & 0x1F; timespec->tm_hour = (when >> 11) & 0x1F; timespec->tm_min = (when >> 5) & 0x3F; timespec->tm_sec = (when & 0x1F) << 1; + timespec->tm_isdst = -1; } private: ZipUtils() {} |