From 831b072936faadb8c3535c613669fd454454f4f2 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 13 Jan 2021 10:11:18 -0800 Subject: [PATCH] Add idmap completely parsed assertion If LoadedIdmap::Load finishes parsing the idmap file but has not parsed the entire file, then it parsed the file incorrectly. Log an error if the idmap fails to parse. Bug: 174676094 Test: libandroidfw_tests Change-Id: I8ae7ed525715ab907d5813975c1ef5d1260bbd33 --- libs/androidfw/Idmap.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/androidfw/Idmap.cpp b/libs/androidfw/Idmap.cpp index 73e040c428268..adb383f95d40b 100644 --- a/libs/androidfw/Idmap.cpp +++ b/libs/androidfw/Idmap.cpp @@ -326,6 +326,11 @@ std::unique_ptr LoadedIdmap::Load(const StringPiece& idmap_pa } } + if (data_size != 0) { + LOG(ERROR) << "idmap parsed with " << data_size << "bytes remaining"; + return {}; + } + // Can't use make_unique because LoadedIdmap constructor is private. return std::unique_ptr( new LoadedIdmap(idmap_path.to_string(), header, data_header, target_entries,