Repository navigation
audren: validate command lists before capture diagnostics - #802
thehobbit85 wants to merge 2 commits into
Conversation
Validate the complete command list before histogram discovery or PCM output, and stop histogram appends before their snprintf return value can leave the buffer. Cover malformed later lists, stereo recovery across supported layouts, and oversized histograms with native regression cases. Related to seedds#313 (comment)
898145e to
3b38941
Compare
Validate the complete command list before histogram discovery or PCM output. Initialize the histogram and stop appends before snprintf's untruncated length can advance beyond the buffer. The regression fixture covers malformed-list rejection and stereo recovery across SDK 4/5/6/16/21, plus oversized histogram formatting. The previous code reproduces both bounds violations under ASan/UBSan; the fixed fixture passes plain and sanitized with patterned stack locals. Co-authored-by: Eliran Zach <[email protected]>
|
Landed on main as b8ffaf8, keeping this as its own small fix. @thehobbit85 is credited as co-author because the implementation and regression coverage were retained. Design and correctness review found no blockers: complete structural validation precedes discovery and PCM output, and histogram formatting respects snprintf's return contract. This is a general root-cause fix with no game-specific rule or workaround. Independently reproduced both original bounds violations under ASan/UBSan. The fixed layout fixture passes plain and unsuppressed ASan/UBSan with patterned stack locals, including malformed-list rejection, recovery across SDK 4/5/6/16/21, and the oversized histogram. The combined landing also passes the focused filesystem/save-sync fixtures and all 11 documentation checks. Published PR CI was green. Confidence is high. Regression risk is low because valid-list PCM behavior is preserved; no gameplay regression or listening pass was run. Closing as landed. |
Validate the complete command list before histogram discovery or PCM output. Initialize the histogram and stop appends before snprintf's untruncated length can advance beyond the buffer. The regression fixture covers malformed-list rejection and stereo recovery across SDK 4/5/6/16/21, plus oversized histogram formatting. The previous code reproduces both bounds violations under ASan/UBSan; the fixed fixture passes plain and sanitized with patterned stack locals. Co-authored-by: Eliran Zach <[email protected]>
What and why
A short valid audio command list can select the SDK layout before the first full list arrives. If that next list is malformed,
captureused to log an uninitialized histogram string or consume sink discovery from a valid prefix. A long histogram also advanced its next append past the buffer aftersnprintftruncated an entry.Validate every command before histogram discovery or PCM output. Initialize the histogram string and stop at the last complete entry that fits. Malformed lists leave discovery pending for the next valid list. The existing native layout test now covers first/middle/trailing malformed commands, stereo recovery across SDK 4/5/6/16/21, and 64,000 synthetic commands whose histogram exceeds the buffer.
Related to #313 (comment). This addresses only the audio finding; the roadmap remains open. Checked current diffs of overlapping PRs #160, #193, #231 and #444, plus the earlier startup-layout fix #331: none resolves these paths.
Initial validation on
898145e5tsan-threads, and native Mac host build pass (GAME=010015100B514000).clang-tidyis absent, so C lint could not run. No tools were installed.Docs
The mechanism and synthetic reproductions are in
docs/reference/audio.md; the symptom index is regenerated. No game files, keys, or extracted game data are included.CI follow-up and main integration
Rebased onto main
5474c6f3and replaced the two new test-onlyrewindcalls with checkedfseekcalls, addressing CI'sbugprone-unsafe-functionsfindings without changing its lint baseline. Published head:3b389417. Full host suite, focused audio capture tests, pattern-initialized ASan/UBSan and documentation tests pass on this head. LLVM 23 remains unavailable locally, so the new CI run must confirm clang-tidy.