CVE-2026-58949 AI-generated analysis
platform/frameworks/av, libmediaplayerservice (StagefrightMetadataRetriever)
Replaces an unbounded sprintf("%f") into a 32-byte stack buffer with snprintf(tmp, sizeof(tmp), ...) in StagefrightMetadataRetriever::parseMetaData so that a large capture-framerate float can no longer overflow the stack buffer.
Root cause
In media/libmediaplayerservice/StagefrightMetadataRetriever.cpp, parseMetaData() declares `char tmp[32]` and reuses it for several formatted values. For the capture framerate it called `sprintf(tmp, "%f", captureFps)`, where captureFps comes from meta->findFloat(kKeyCaptureFramerate, ...). The commit message says an attacker-supplied float such as FLT_MAX can produce up to 47 bytes of output. That exceeds the 32-byte stack buffer and overflows the stack.
How the fix works
- media/libmediaplayerservice/StagefrightMetadataRetriever.cpp : StagefrightMetadataRetriever::parseMetaData(): the single call `sprintf(tmp, "%f", captureFps)` becomes `snprintf(tmp, sizeof(tmp), "%f", captureFps)`. snprintf never writes more than sizeof(tmp) bytes, including the terminating NUL, so over-long output is cut to 31 characters instead of overflowing the buffer.
- The value itself is unchanged: captureFps is not validated or clamped. The string stored under METADATA_KEY_CAPTURE_FRAMERATE is simply the formatted text, which may be truncated.
Completeness
- In the shown part of parseMetaData(), this is the only sprintf whose output length depends on a float, and it was the overflow path.
- The other sprintf calls on the same `tmp[32]` buffer in parseMetaData() are left as sprintf: "%zu" for numTracks and "%lld" for exifOffset, exifSize, xmpOffset and xmpSize. Their maximum output (about 20 characters plus NUL) fits in 32 bytes, so format width cannot overflow them, but they are not hardened to snprintf either.
- The fix truncates rather than rejects: a huge framerate value now produces a truncated numeric string in the metadata map, and the fix does not treat it as an error.
Behavior changes
- When the "%f" rendering of the capture framerate is longer than 31 characters, METADATA_KEY_CAPTURE_FRAMERATE now holds a truncated string instead of overflowing the stack buffer. Values in the normal range are formatted exactly as before.
- No new error codes, return paths or logging.
Per major
- Android 14: same fix: commit 396376ffec51 in android-security-14.0.0_r31, the same one-line sprintf to snprintf change in the same hunk (starting at line 575).
- Android 15: same fix: commit b211f5bcc1d4 in android-security-15.0.0_r19, a one-line sprintf to snprintf change in parseMetaData() (the changed call is at line 578).
- Android 16: same fix: commit 4d02a21c22a6 in android-security-16.0.0_r10. The diff and file blob ids (605e659d4e -> 6173ac005b) are identical to Android 15.
- Android 17: same fix: commit ee1ea25e82e5 in android-security-17.0.0_r3, the same one-line change, with the hunk starting at line 614.
Unknowns
- Which extractor or container format supplies kKeyCaptureFramerate from attacker-controlled file content, and where `meta` is obtained.
- The process in which the overflow occurs, and any impact beyond the bulletin's DoS classification.
- Whether the two internal Cherrypick-From changes named in the commit message differ from the public one-line diff.
- Why the Android 17 hunk offset differs.