summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetManager.cpp
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2015-06-16 12:02:57 +0100
committerNarayan Kamath <narayan@google.com>2015-06-17 13:13:16 +0000
commit407753c456c1eb2c8556ae7891b6bef43b044e76 (patch)
tree8dcc64a1dd532071a5a626821bc4d54abd6a3b4d /libs/androidfw/AssetManager.cpp
parentdc22cfed5d3a65dcd3979113dbce468ad8ec2868 (diff)
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 (cherry picked from commit 4600dd053dbdbd4b95f3b11057a1cc55b99f9c77) Change-Id: I7886cb37a229cc27c625699c80e6a6a6117d2203
Diffstat (limited to 'libs/androidfw/AssetManager.cpp')
-rw-r--r--libs/androidfw/AssetManager.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index 25cd3632bfdb..2dc1c96259c0 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -1156,13 +1156,11 @@ Asset* AssetManager::openAssetFromZipLocked(const ZipFileRO* pZipFile,
Asset* pAsset = NULL;
// TODO: look for previously-created shared memory slice?
- int method;
- size_t uncompressedLen;
+ uint16_t method;
+ uint32_t uncompressedLen;
//printf("USING Zip '%s'\n", pEntry->getFileName());
- //pZipFile->getEntryInfo(entry, &method, &uncompressedLen, &compressedLen,
- // &offset);
if (!pZipFile->getEntryInfo(entry, &method, &uncompressedLen, NULL, NULL,
NULL, NULL))
{
@@ -1181,8 +1179,8 @@ Asset* AssetManager::openAssetFromZipLocked(const ZipFileRO* pZipFile,
ALOGV("Opened uncompressed entry %s in zip %s mode %d: %p", entryName.string(),
dataMap->getFileName(), mode, pAsset);
} else {
- pAsset = Asset::createFromCompressedMap(dataMap, method,
- uncompressedLen, mode);
+ pAsset = Asset::createFromCompressedMap(dataMap,
+ static_cast<size_t>(uncompressedLen), mode);
ALOGV("Opened compressed entry %s in zip %s mode %d: %p", entryName.string(),
dataMap->getFileName(), mode, pAsset);
}