summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2018-05-30 12:17:01 -0700
committerTim Schumacher <timschumi@gmx.de>2018-08-08 21:10:34 +0200
commit44511f01264970aa34cd76c26070fb2fb464a4b7 (patch)
tree16d97ee36d58587545fcf93d2a85591d2188c868
parente8dc0fe9b20af7d2f88746849124531927d9a3ee (diff)
downloadframeworks_base-44511f01264970aa34cd76c26070fb2fb464a4b7.tar.gz
frameworks_base-44511f01264970aa34cd76c26070fb2fb464a4b7.tar.bz2
frameworks_base-44511f01264970aa34cd76c26070fb2fb464a4b7.zip
Fix DynamicRefTable::load security bug
DynamicRefTables parsed from apks are missing bounds checks that prevent buffer overflows. This changes verifies the bounds of the header before attempting to preform operations on the chunk. Bug: 79488511 Test: run cts -m CtsAppSecurityHostTestCases \ -t android.appsecurity.cts.CorruptApkTests Change-Id: I02c8ad957da244fce777ac68a482e4e8fa70f846 Merged-In: I02c8ad957da244fce777ac68a482e4e8fa70f846 (cherry picked from commit 18a6ada4aa136da4f50f03fff91d61d448ced195)
-rw-r--r--libs/androidfw/ResourceTypes.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 109619bf84a..da3f5c6d0a9 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -6376,8 +6376,16 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
}
} else if (ctype == RES_TABLE_LIBRARY_TYPE) {
+
if (group->dynamicRefTable.entries().size() == 0) {
- status_t err = group->dynamicRefTable.load((const ResTable_lib_header*) chunk);
+ const ResTable_lib_header* lib = (const ResTable_lib_header*) chunk;
+ status_t err = validate_chunk(&lib->header, sizeof(*lib),
+ endPos, "ResTable_lib_header");
+ if (err != NO_ERROR) {
+ return (mError=err);
+ }
+
+ err = group->dynamicRefTable.load(lib);
if (err != NO_ERROR) {
return (mError=err);
}