diff options
author | 2023-10-11 12:56:19 +0100 | |
---|---|---|
committer | 2023-10-25 14:17:55 +0000 | |
commit | 876085b17f2bc5efe6b64eee4ddc1be4e967a4f1 (patch) | |
tree | 68c201c1990d300cba2324988c43ce7cfa80f4d4 /libdexfile/dex/dex_file_loader.h | |
parent | c13ae9cfc8883372637fb43d2c16b527cd2a5d2a (diff) |
Extend memory range of DexFileContainer passed to Dex loader.
Pass the whole relevant memory range (possibly including some
surrounding non-dex data).
If dex file shares data with other dex files, this will make
it possible to verify that all referred data is within bounds
of valid memory.
Test: ./art/test.py -b --host 001
Change-Id: I5e0058411db4baa3dbe74bfbd7c99d75c9afd694
Diffstat (limited to 'libdexfile/dex/dex_file_loader.h')
-rw-r--r-- | libdexfile/dex/dex_file_loader.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/libdexfile/dex/dex_file_loader.h b/libdexfile/dex/dex_file_loader.h index ec5f64a9d6..be3359b98f 100644 --- a/libdexfile/dex/dex_file_loader.h +++ b/libdexfile/dex/dex_file_loader.h @@ -180,17 +180,28 @@ class DexFileLoader { virtual ~DexFileLoader() {} - std::unique_ptr<const DexFile> Open(uint32_t location_checksum, + std::unique_ptr<const DexFile> Open(size_t header_offset, + uint32_t location_checksum, const OatDexFile* oat_dex_file, bool verify, bool verify_checksum, std::string* error_msg); std::unique_ptr<const DexFile> Open(uint32_t location_checksum, + const OatDexFile* oat_dex_file, + bool verify, + bool verify_checksum, + std::string* error_msg) { + return Open( + /*header_offset=*/0, location_checksum, oat_dex_file, verify, verify_checksum, error_msg); + } + + std::unique_ptr<const DexFile> Open(uint32_t location_checksum, bool verify, bool verify_checksum, std::string* error_msg) { - return Open(location_checksum, + return Open(/*header_offset=*/0, + location_checksum, /*oat_dex_file=*/nullptr, verify, verify_checksum, @@ -243,7 +254,7 @@ class DexFileLoader { protected: static const File kInvalidFile; // Used for "no file descriptor" (-1). - bool InitAndReadMagic(uint32_t* magic, std::string* error_msg); + bool InitAndReadMagic(size_t header_offset, uint32_t* magic, std::string* error_msg); // Ensure we have root container. If we are backed by a file, memory-map it. // We can only do this for dex files since zip files might be too big to map. |