diff options
author | Narayan Kamath <narayan@google.com> | 2015-06-16 12:02:57 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2015-06-17 08:40:25 +0000 |
commit | 4600dd053dbdbd4b95f3b11057a1cc55b99f9c77 (patch) | |
tree | c4bb116de6b55b054a73083165c9512fbf21c164 /cmds/idmap | |
parent | 5e063b1da52cca1b93b19bdf7be694aabf95d336 (diff) | |
download | frameworks_base-4600dd053dbdbd4b95f3b11057a1cc55b99f9c77.zip frameworks_base-4600dd053dbdbd4b95f3b11057a1cc55b99f9c77.tar.gz frameworks_base-4600dd053dbdbd4b95f3b11057a1cc55b99f9c77.tar.bz2 |
ZipFileRO: Use precise widths for zip file types.
getEntryInfo crashes on 64-bit devices because "long" types
were being passed int pointers (that pointed to a stack frame)
that were reinterpret_cast'ed to long* (sigh.). To fix this issue
once and for all, use types with explicitly defined widths.
This change also removes some dead invariant checking from
Asset.cpp instead of cleaning it up.
Note that we've introduced a wart in NativeLibraryHelper, where
we need to deal with zlib's uLong type, which is "at least 32 bits
wide".
bug: 21622286
Change-Id: Iae675a9601db7aae03a8b80b40321d2cc1d97f50
Diffstat (limited to 'cmds/idmap')
-rw-r--r-- | cmds/idmap/create.cpp | 2 | ||||
-rw-r--r-- | cmds/idmap/scan.cpp | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/cmds/idmap/create.cpp b/cmds/idmap/create.cpp index 16532b8..41395f1 100644 --- a/cmds/idmap/create.cpp +++ b/cmds/idmap/create.cpp @@ -23,7 +23,7 @@ namespace { if (entry == NULL) { return -1; } - if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, reinterpret_cast<long*>(crc))) { + if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, crc)) { return -1; } zip->releaseEntry(entry); diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp index 84158d3..612a7eb 100644 --- a/cmds/idmap/scan.cpp +++ b/cmds/idmap/scan.cpp @@ -1,4 +1,5 @@ #include <dirent.h> +#include <inttypes.h> #include <sys/stat.h> #include "idmap.h" @@ -130,14 +131,14 @@ namespace { ALOGW("%s: failed to find entry AndroidManifest.xml\n", __FUNCTION__); return -1; } - size_t uncompLen = 0; - int method; + uint32_t uncompLen = 0; + uint16_t method; if (!zip->getEntryInfo(entry, &method, &uncompLen, NULL, NULL, NULL, NULL)) { ALOGW("%s: failed to read entry info\n", __FUNCTION__); return -1; } if (method != ZipFileRO::kCompressDeflated) { - ALOGW("%s: cannot handle zip compression method %d\n", __FUNCTION__, method); + ALOGW("%s: cannot handle zip compression method %" PRIu16 "\n", __FUNCTION__, method); return -1; } FileMap *dataMap = zip->createEntryFileMap(entry); @@ -147,19 +148,19 @@ namespace { } char *buf = new char[uncompLen]; if (NULL == buf) { - ALOGW("%s: failed to allocate %zd byte\n", __FUNCTION__, uncompLen); + ALOGW("%s: failed to allocate %" PRIu32 " byte\n", __FUNCTION__, uncompLen); delete dataMap; return -1; } StreamingZipInflater inflater(dataMap, uncompLen); if (inflater.read(buf, uncompLen) < 0) { - ALOGW("%s: failed to inflate %zd byte\n", __FUNCTION__, uncompLen); + ALOGW("%s: failed to inflate %" PRIu32 " byte\n", __FUNCTION__, uncompLen); delete[] buf; delete dataMap; return -1; } - int priority = parse_manifest(buf, uncompLen, target_package_name); + int priority = parse_manifest(buf, static_cast<size_t>(uncompLen), target_package_name); delete[] buf; delete dataMap; return priority; |