summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ryan Mitchell <rtmitchell@google.com> 2019-08-26 16:06:34 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-08-26 16:06:34 +0000
commit11fef4e7d4447bbf5a285f2f04ffbc47419e0bbd (patch)
treeac8b8d00232337d7877b09f743391c295d7a7de9
parent007ecbb8598d631acc35dba4562148f6e706cac8 (diff)
parent8da1c38b69e947885fcec50cda46c5472ddb6746 (diff)
Merge "Fix security issue in DynamicRefTable::load."
-rw-r--r--libs/androidfw/ResourceTypes.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 2ad2e76cc696..8a035dbbc0f5 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -6902,9 +6902,8 @@ std::unique_ptr<DynamicRefTable> DynamicRefTable::clone() const {
status_t DynamicRefTable::load(const ResTable_lib_header* const header)
{
const uint32_t entryCount = dtohl(header->count);
- const uint32_t sizeOfEntries = sizeof(ResTable_lib_entry) * entryCount;
const uint32_t expectedSize = dtohl(header->header.size) - dtohl(header->header.headerSize);
- if (sizeOfEntries > expectedSize) {
+ if (entryCount > (expectedSize / sizeof(ResTable_lib_entry))) {
ALOGE("ResTable_lib_header size %u is too small to fit %u entries (x %u).",
expectedSize, entryCount, (uint32_t)sizeof(ResTable_lib_entry));
return UNKNOWN_ERROR;