CVE-2026-58995 AI-generated analysis
platform/frameworks/base, libs/androidfw (ZipFileRO)
Changes the type of requiredSize in ZipFileRO::getEntryFileName from uint16_t to size_t so that a maximum-length (65535 byte) Zip entry name no longer wraps the required-size computation to 0 and bypasses the caller buffer length check.
Root cause
In libs/androidfw/ZipFileRO.cpp, ZipFileRO::getEntryFileName computed `const uint16_t requiredSize = zipEntry->name.length() + 1;`. Zip entry names can be up to 65535 bytes (per the commit message). For a 65535 byte name, the value 65536 is truncated to 0 when stored in uint16_t. The following check `if (bufLen < requiredSize)` then never fails, so the function proceeds past the guard even when the caller's buffer may be far smaller than the name plus terminator (the new test uses a 4096 byte buffer). The ALOGW also printed requiredSize with %d.
How the fix works
- libs/androidfw/ZipFileRO.cpp:ZipFileRO::getEntryFileName: requiredSize is now `const size_t`, so name.length() + 1 is held without truncation. The existing `bufLen < requiredSize` check now correctly rejects buffers shorter than 65536 bytes for a max-length name and returns requiredSize (65536) to the caller.
- libs/androidfw/ZipFileRO.cpp:ZipFileRO::getEntryFileName: the ALOGW format specifier is changed from %d to %zu to match the new size_t type.
- libs/androidfw/include/androidfw/ZipFileRO.h: adds `friend class ZipFileROTest_GetEntryFileName_MaxLengthOverflow_Test;` in the private section so the new gtest can use the private ZipFileRO(ZipArchiveHandle, char*) constructor.
- libs/androidfw/tests/ZipFileRO_test.cpp (new) and libs/androidfw/Android.bp: add the test GetEntryFileName_MaxLengthOverflow. It builds a fake _ZipEntryRO with a 65535 byte name, calls getEntryFileName with a 4096 byte buffer, and expects a return value of 65536 and buffer[0] to still be '\0'.
Completeness
- The fix covers the single truncation site in ZipFileRO::getEntryFileName. The check logic itself is unchanged and now operates on an untruncated size_t.
- The return type of getEntryFileName remains int. The value 65536 fits, so no new truncation is introduced for the Zip name length range.
- No other size computations in ZipFileRO.cpp are touched by the diff. The material shows only part of the file, so other code paths in it cannot be judged.
- Callers of getEntryFileName are not changed. As before, correctness still depends on callers handling the non-zero return value when their buffer is too short.
Behavior changes
- For an entry name of 65535 bytes, getEntryFileName now returns 65536 when bufLen < 65536 instead of proceeding past the check.
- The warning log now prints the required size as an unsigned size_t (%zu).
- A new unit test, ZipFileRO_test.cpp, is compiled into libandroidfw_tests.
Per major
- Android 14: same fix: platform/frameworks/base 8a4029cc87f6 in android-security-14.0.0_r31. Content is identical to the Android 15 change, with different hunk offsets (ZipFileRO.cpp @@ -194, ZipFileRO.h @@ -181, Android.bp @@ -185). 7/8 lines of the patched region are present at that tag.
- Android 15: same fix: platform/frameworks/base 433f70a3315e in android-security-15.0.0_r19 (the analysed commit). 7/8 lines of the patched region are present at that tag.
- Android 16: same fix: platform/frameworks/base 4236e07ecb22 in android-security-16.0.0_r10. The ZipFileRO.cpp and ZipFileRO.h hunks are identical, and the Android.bp hunk is at @@ -237. 7/8 lines of the patched region are present at that tag.
- Android 17: same fix: platform/frameworks/base 365f2a1086de in android-security-17.0.0_r3. The ZipFileRO.cpp and ZipFileRO.h hunks are identical, and the Android.bp context differs slightly (static_libs list). 6/8 lines of the patched region are present at that tag.
Unknowns
- The code after the bufLen check in getEntryFileName (the copy into buffer) is not included in the material. The exact consequence of the bypassed check is inferred only from the test comment about not touching a buffer that is too small.
- The material does not show which production callers pass attacker-controlled archives and small buffers to getEntryFileName.
- The bulletin lists EoP/High, but the material does not show the reporter's trigger or the affected process.
- The material does not say which lines make up the 8-line patched region, so the 7/8 and 6/8 counts are not explained.