diff options
| author | 2016-01-29 12:22:17 -0800 | |
|---|---|---|
| committer | 2016-01-29 14:23:13 -0800 | |
| commit | 9ff846053a33db95fcf739831baf55eb7e1ce243 (patch) | |
| tree | 939bcdc6b162d9720c81e90da17a8b5b10f92f63 | |
| parent | ab00be9c6e2706be3499bd189637e27edf7f2168 (diff) | |
Add oat checksum check for app image loading
Bug: 26846419
Bug: 22858531
Change-Id: If30028b7d6b5749f5bdbed0c219d014a3b50a11b
| -rw-r--r-- | runtime/gc/space/image_space.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index f6079232bf..998db5271a 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -1167,6 +1167,20 @@ ImageSpace* ImageSpace::Init(const char* image_filename, return nullptr; } + if (oat_file != nullptr) { + // If we have an oat file, check the oat file checksum. The oat file is only non-null for the + // app image case. Otherwise, we open the oat file after the image and check the checksum there. + const uint32_t oat_checksum = oat_file->GetOatHeader().GetChecksum(); + const uint32_t image_oat_checksum = image_header->GetOatChecksum(); + if (oat_checksum != image_oat_checksum) { + *error_msg = StringPrintf("Oat checksum 0x%x does not match the image one 0x%x in image %s", + oat_checksum, + image_oat_checksum, + image_filename); + return nullptr; + } + } + if (VLOG_IS_ON(startup)) { LOG(INFO) << "Dumping image sections"; for (size_t i = 0; i < ImageHeader::kSectionCount; ++i) { |