Repository navigation
Fix CDEX containerSize and mapOffset validation in DexBackedDexFile - #105
Merged
Merged
Conversation
Commit e99622b8 introduced validation of mapOffset against containerSize. For Compact DEX (CDEX) files: 1. containerSize was capped at fileSize (which covers only the unshared section header and ID tables, excluding the data section). 2. mapOffset is relative to baseDataOffset (the data section), but mapSize was eagerly read from dexBuffer instead of dataBuffer, reading garbage data from absolute offset mapOffset. Update containerSize calculation for CDEX headers to encompass dataStart + dataSize, use dataBuffer to read mapSize at mapOffset, and use overflow-safe bounds checking. TAG=agy CONV=63f64982-065a-4b9f-a2d3-6fa7ad565aa6 Bug: 535190835 Bug: 285129432 Test: ./gradlew :dexlib2:test --tests com.android.tools.smali.dexlib2.dexbacked.CDexTest Flag: EXEMPT BUGFIX Change-Id: I6249049af4d31d13cf0b66f36fbb0e2dd9dcb55a
sgjesse
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit e99622b8 introduced validation of mapOffset against containerSize. For Compact DEX (CDEX) files: 1. containerSize was capped at fileSize (which covers only the unshared section header and ID tables, excluding the data section). 2. mapOffset is relative to baseDataOffset (the data section), but mapSize was eagerly read from dexBuffer instead of dataBuffer, reading garbage data from absolute offset mapOffset. Update containerSize calculation for CDEX headers to encompass dataStart + dataSize, use dataBuffer to read mapSize at mapOffset, and use overflow-safe bounds checking.