Skip to content

Upstream recent changes from Android - #103

Merged
sgjesse merged 8 commits into
google:mainfrom
dsrbecky:main
Jul 14, 2026
Merged

sgjesse merged 8 commits into
google:mainfrom
dsrbecky:main

Conversation

@dsrbecky

Copy link
Copy Markdown
Collaborator

No description provided.

dsrbecky and others added 8 commits July 14, 2026 13:32
Test: m android-smali
Test: ./gradlew assemble
Change-Id: I74961a1c88d0de8055ecf5ca7b35557286044369
Correct the count validation logic in StringUtils.repeat.
Previously, a count of 0 or 1 was incorrectly treated as invalid,
and a negative count did not throw an IllegalArgumentException.

Test: ./gradlew :dexlib2:test
Flag: EXEMPT bugfix
TAG=agy
CONV=8b50a6b3-6ed8-4255-859d-a4739fc9b48a

Change-Id: I7d0118a22fb468d6e49620d82d1674f6da989eb0
Regenerated the smali parser, lexer, and tree walker using updated
scripts that use relative paths. This avoids embedding absolute paths
of the build environment in the generated Java files.

Updated the helper scripts to cd to the project directory before
running the generators:
- smali/run_antlr.sh
- smali/run_jflex.sh

Bug: None
Test: ./gradlew clean test -x :smali:generateGrammarSource -x :smali:jflex
Flag: EXEMPT refactoring

TAG=agy
CONV=7fa249f9-41b5-437f-baeb-29303ea91886

Change-Id: I69c20fe194b4bd068b72fd808309baa38bbbc65d
Eagerly read and validate mapSize to ensure it does not extend beyond
the container bounds. Also validate mapOffset.

This prevents ArrayIndexOutOfBoundsException when parsing malformed
DEX files with corrupted map size/offset.

Test: test on corrupt apk
Change-Id: I3e805ebe8a1deb5e24713e7c2846daccb5221587
Making getDebugOffset() public allows external tools to
access the debug offset and calculate method/class sizes
while properly handling debug info duplication.

Change-Id: I56321c16d0ee6769c9fbd7041d826ef7dcb6b150
Replacing Collections.emptySortedSet() (which requires API 26) with
Collections.unmodifiableSortedSet(new TreeSet()) to support API 23.

Bug: 285129432
Test: ./gradlew :dexlib2:test
Flag: NONE tool compatibility fix

TAG=agy
CONV=1ea891e6-8562-4a15-8bba-16a2d9b01b34

Change-Id: I6880b22ff0b455128e9bd1572ac2a0e177b6767e
Improve ZipDexContainer to handle invalid dex entries. It now allows
registering invalid entries and throws when they are accessed, or
ignores them if configured to do so. Also update DexBackedDexFile to
throw InvalidFile instead of IndexOutOfBoundsException for invalid
offsets.

Bug: 285129432
Test: ./gradlew :dexlib2:test

TAG=agy
CONV=1ea891e6-8562-4a15-8bba-16a2d9b01b34

Change-Id: I7cba6f96809be00aca247dcc7c22b5ac1f988b3f
In OatHeader.getKeyValue(String key), when iterating through key-value store, if the current key k didn't match the requested key, offset was incremented by only 1 byte (moving it to the value), causing the loop to treat the value as a key in the next iteration.

The format of the OAT key-value store is key1\0value1\0key2\0value2\0.... When a key does not match, the parser must skip BOTH the key and its corresponding value. The code only incremented offset++ once, which just skips the null terminator of the key, starting the next key search inside the value string.

Change-Id: Ib8be875e9bdfe50cb88412c9399f46cc6b11f748
@sgjesse
sgjesse self-requested a review July 14, 2026 13:11
@sgjesse
sgjesse merged commit b353f17 into google:main Jul 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants