diff options
author | Todd Kennedy <toddke@google.com> | 2018-07-12 13:15:54 -0700 |
---|---|---|
committer | Todd Kennedy <toddke@google.com> | 2018-07-16 20:52:55 +0000 |
commit | 28e663cbed28fb6c8c8dec0849e0277daf67651b (patch) | |
tree | 7d0ddd6373a15fbbf69f878c61eafc571c2eccea /libs/androidfw/ChunkIterator.cpp | |
parent | 4ab42d5b8aa2cb2e36f46b34962dd23832f45280 (diff) |
Loosen resource file verification
Bug: 77808145
Test: Tried to install corrupt APK prior to the change, install failed
Test: Tried to install corrupt APK after the change, install succeeded
Test: atest CtsAppSecurityHostTestCases:CorruptApkTests
Change-Id: I19a69e52a17c1080beaf2cc575c32f564b1033a3
Diffstat (limited to 'libs/androidfw/ChunkIterator.cpp')
-rw-r--r-- | libs/androidfw/ChunkIterator.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libs/androidfw/ChunkIterator.cpp b/libs/androidfw/ChunkIterator.cpp index d8adbe5ac85d..8fc321968055 100644 --- a/libs/androidfw/ChunkIterator.cpp +++ b/libs/androidfw/ChunkIterator.cpp @@ -32,11 +32,30 @@ Chunk ChunkIterator::Next() { if (len_ != 0) { // Prepare the next chunk. - VerifyNextChunk(); + if (VerifyNextChunkNonFatal()) { + VerifyNextChunk(); + } } return Chunk(this_chunk); } +// TODO(b/111401637) remove this and have full resource file verification +// Returns false if there was an error. +bool ChunkIterator::VerifyNextChunkNonFatal() { + if (len_ < sizeof(ResChunk_header)) { + last_error_ = "not enough space for header"; + last_error_was_fatal_ = false; + return false; + } + const size_t size = dtohl(next_chunk_->size); + if (size > len_) { + last_error_ = "chunk size is bigger than given data"; + last_error_was_fatal_ = false; + return false; + } + return true; +} + // Returns false if there was an error. bool ChunkIterator::VerifyNextChunk() { const uintptr_t header_start = reinterpret_cast<uintptr_t>(next_chunk_); |