CVE-2026-59007 AI-generated analysis
platform/external/tremolo, the Tremolo Vorbis decoder's codebook decoding (used by the software Vorbis decoders in frameworks/av, per index search)
Removes the hand-written arm32 assembly version of the Huffman codebook walk decode_packed_entry_number from Tremolo/dpen.s, so the C version in Tremolo/codebook.c is the only one on all architectures. This removes an early-exit bug in the asm walk that could cause an out-of-bounds read.
Root cause
When ONLY_C was not defined (arm32 builds, per the commit message), decode_packed_entry_number came from hand-written assembly in Tremolo/dpen.s instead of the C code in Tremolo/codebook.c. The commit message says the asm walk has an early-exit bug that can lead to an OOB read. Reading the removed code: in the meth0, meth2 and meth4 paths the loop counter r1 holds i-read. It reaches 0 in two cases: when a leaf is found on the last of 'read' bits, and when all 'read' bits are used up without reaching a leaf. The check after the loop is 'CMP r1,#0 / MVNGT r7,#0', which returns -1 only when i-read > 0, although the inline comment says the intent is '(i >= read)'. So when the walk runs out of bits, it seems it can return a non-leaf table value as the entry number instead of -1. The C function, by contrast, has a final 'oggpack_adv(b,read+1); return(-1);' path. This exact failing path is inferred from the removed asm. The commit message says only 'early exit huffman walk bug'.
How the fix works
- Tremolo/codebook.c:decode_packed_entry_number: removes the split between the '#ifndef ONLY_C' extern declaration and the '#else' static inline definition. The C version is now an unconditional, non-static function 'ogg_uint32_t decode_packed_entry_number(codebook *book, oggpack_buffer *b)', so it is compiled and linked on every architecture, including arm32. The body of the C function does not change.
- Tremolo/dpen.s: deletes the asm decode_packed_entry_number and decode_packed_entry_number_REALSTART code (method paths meth0 to meth4, dpen_nobits, dpen_readfailed, duff), their .global/.type lines, and the .extern oggpack_adv/oggpack_look declarations. Adds '.extern decode_packed_entry_number' so that the remaining asm routine decode_map, which does 'BL decode_packed_entry_number', now calls the C function.
- No new bounds check is added. The fix replaces the faulty asm with the existing C code.
Completeness
- Covers all five dec_method variants (0 to 4) of the asm walk, because the whole asm function is removed rather than patched.
- Only decode_packed_entry_number moves to C. decode_map, vorbis_book_decodevv_add and _checksum stay as hand-written arm32 assembly in Tremolo/dpen.s and are not changed by this commit.
- Per the commit message, other architectures already used the C version.
Behavior changes
- On arm32, codebook entry lookup now runs the C code, the same as on other architectures. Malformed input that makes the walk run out of bits now follows the C error handling (which can return -1) instead of the asm result.
- decode_packed_entry_number becomes an external symbol (no longer static or inline) on all builds. Its signature does not change.
Per major
- Android 14: same fix: platform/external/tremolo 236d8edc0c7b in android-security-14.0.0_r31, identical diff (same blob ids ae5500a..f1fba89 and cc492cf..07b7fd0)
- Android 15: same fix: platform/external/tremolo 178a3474dc42 in android-security-15.0.0_r19, cherry-pick of 7293b0a896ee, identical diff
- Android 16: same fix: platform/external/tremolo 82870ba4268e in android-security-16.0.0_r10, identical diff
- Android 17: same fix: platform/external/tremolo d016b4d203c7 in android-security-17.0.0_r3, identical diff
Unknowns
- The exact malformed-input condition, and which asm method path was seen to read out of bounds. The commit message says only 'early exit huffman walk bug'.
- The C function's control flow after the switch, which the context does not fully show.
- Which callers of decode_packed_entry_number exist in codebook.c.
- Whether the remaining asm routines in Tremolo/dpen.s, or other Tremolo .s files, differ from the C code in similar ways.