summaryrefslogtreecommitdiffstats
path: root/src/dex_file_verifier.cc
diff options
context:
space:
mode:
authorjeffhao <jeffhao@google.com>2012-01-31 16:14:17 -0800
committerjeffhao <jeffhao@google.com>2012-01-31 17:48:30 -0800
commitf6174e8a1566bb357e82506f7ec97dc359c90eb2 (patch)
treeb74b1fc81d0dc0b2f2da7ab6f5187493f15a0b66 /src/dex_file_verifier.cc
parent4d9716c19cc25911e639272048abd0d6702bb082 (diff)
downloadart-f6174e8a1566bb357e82506f7ec97dc359c90eb2.zip
art-f6174e8a1566bb357e82506f7ec97dc359c90eb2.tar.gz
art-f6174e8a1566bb357e82506f7ec97dc359c90eb2.tar.bz2
Fix to prevent a dex file from being verified multiple times.
Instead of verifying a dex file whenever one is initialized, they're now verified when not opened from memory. Also, the way dalvik_system_DexFile opens dex files has been changed to check for an existing oat file and get the corresponding dex file from there instead. Change-Id: I75fc26247150107d628e2c4e364ef8a53fbf9481
Diffstat (limited to 'src/dex_file_verifier.cc')
-rw-r--r--src/dex_file_verifier.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/dex_file_verifier.cc b/src/dex_file_verifier.cc
index e731c1b..eb06e2a 100644
--- a/src/dex_file_verifier.cc
+++ b/src/dex_file_verifier.cc
@@ -99,8 +99,8 @@ static bool CheckShortyDescriptorMatch(char shorty_char, const char* descriptor,
return true;
}
-bool DexFileVerifier::Verify(DexFile* dex_file, const byte* begin, size_t length) {
- UniquePtr<DexFileVerifier> verifier(new DexFileVerifier(dex_file, begin, length));
+bool DexFileVerifier::Verify(const DexFile* dex_file, const byte* begin, size_t size) {
+ UniquePtr<DexFileVerifier> verifier(new DexFileVerifier(dex_file, begin, size));
return verifier->Verify();
}
@@ -108,7 +108,7 @@ bool DexFileVerifier::CheckPointerRange(const void* start, const void* end, cons
uint32_t range_start = reinterpret_cast<uint32_t>(start);
uint32_t range_end = reinterpret_cast<uint32_t>(end);
uint32_t file_start = reinterpret_cast<uint32_t>(begin_);
- uint32_t file_end = file_start + length_;
+ uint32_t file_end = file_start + size_;
if ((range_start < file_start) || (range_start > file_end) ||
(range_end < file_start) || (range_end > file_end)) {
LOG(ERROR) << StringPrintf("Bad range for %s: %x to %x", label,
@@ -133,10 +133,10 @@ bool DexFileVerifier::CheckIndex(uint32_t field, uint32_t limit, const char* lab
}
bool DexFileVerifier::CheckHeader() const {
- // Check file length from the header.
- uint32_t expected_length = header_->file_size_;
- if (length_ != expected_length) {
- LOG(ERROR) << "Bad file length (" << length_ << ", expected " << expected_length << ")";
+ // Check file size from the header.
+ uint32_t expected_size = header_->file_size_;
+ if (size_ != expected_size) {
+ LOG(ERROR) << "Bad file size (" << size_ << ", expected " << expected_size << ")";
return false;
}
@@ -144,7 +144,7 @@ bool DexFileVerifier::CheckHeader() const {
uint32_t adler_checksum = adler32(0L, Z_NULL, 0);
const uint32_t non_sum = sizeof(header_->magic_) + sizeof(header_->checksum_);
const byte* non_sum_ptr = reinterpret_cast<const byte*>(header_) + non_sum;
- adler_checksum = adler32(adler_checksum, non_sum_ptr, expected_length - non_sum);
+ adler_checksum = adler32(adler_checksum, non_sum_ptr, expected_size - non_sum);
if (adler_checksum != header_->checksum_) {
LOG(ERROR) << StringPrintf("Bad checksum (%08x, expected %08x)", adler_checksum, header_->checksum_);
return false;
@@ -157,7 +157,7 @@ bool DexFileVerifier::CheckHeader() const {
}
if (header_->header_size_ != sizeof(DexFile::Header)) {
- LOG(ERROR) << "Bad header length: " << header_->header_size_;
+ LOG(ERROR) << "Bad header size: " << header_->header_size_;
return false;
}
@@ -685,7 +685,7 @@ bool DexFileVerifier::CheckIntraCodeItem() {
bool DexFileVerifier::CheckIntraStringDataItem() {
uint32_t size = DecodeUnsignedLeb128(&ptr_);
- const byte* file_end = begin_ + length_;
+ const byte* file_end = begin_ + size_;
for (uint32_t i = 0; i < size; i++) {
if (ptr_ >= file_end) {
@@ -1121,7 +1121,7 @@ bool DexFileVerifier::CheckIntraSectionIterate(uint32_t offset, uint32_t count,
}
aligned_offset = reinterpret_cast<uint32_t>(ptr_) - reinterpret_cast<uint32_t>(begin_);
- if (aligned_offset > length_) {
+ if (aligned_offset > size_) {
LOG(ERROR) << StringPrintf("Item %d at ends out of bounds", i);
return false;
}