Ignore out-of-range color table indices in OSC 4 and OSC 104 #20991
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 322 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.346
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #20991"
general
weight: 0.35
DHowett
Summary of the Pull Request
This PR prevents
OSC 4(set/query color table entry) andOSC 104(reset color table entry) from addressing indices outside the 256-entry xterm color table, and fixes integer overflow wraparound inUtils::StringToUintby clamping overflowing values toUINT_MAX.References and Relevant Issues
N/A
Detailed Description of the Pull Request / Additional comments
Currently,
OutputStateMachineEnginedoes not bound-check the color table index parsed in_GetOscSetColorTable(OSC 4) orActionOscDispatch(OSC 104):1. Out-of-bounds indices (
>= 256):- Indices in the range
256..266address internal entries at the end ofRenderSettings::_colorTable(such as default foreground/background, cursor color, selection background, etc.) which are meant to be managed via their respective sequences/aliases rather than indexed xterm palette sequences.- Indices
>= 267(TextColor::TABLE_SIZE) cause_colorTable.at(tableIndex)inRenderSettingsto throwstd::out_of_range. When anOSC 4orOSC 104sequence specifies multiple color indices and one of them is out of range (e.g.OSC 4;300;rgb:1/1/1;255;rgb:2/2/2 STorOSC 104;1;300;255 ST), the exception aborts the dispatch loop and prevents any subsequent valid entries in the same sequence from being applied.2. 32-bit unsigned integer wraparound in
Utils::StringToUint:-
Utils::StringToUintaccumulates decimal digits into anunsigned intwithout checking for overflow. As a result, a large index such as4294967297($2^{32} + 1$) silently wraps around to1and modifies or queries color table entry1.- Clamping overflowing values to
UINT_MAXinUtils::StringToUint(matching how CSI parameter accumulation saturates inStateMachine::_AccumulateTo) ensures that huge numbers remain out of range rather than wrapping around to small valid values.Validation Steps Performed
OutputEngineTest(TestOscSetColorTable,TestOscGetColorTableEntry, andTestOscColorTableReset) covering out-of-range indices (256,261,267,300,4294967297) as well as sequences mixing out-of-range and valid indices.UtilsTests::TestStringToUintverifying that values exceedingUINT_MAXsaturate toUINT_MAX.PR Checklist
- If checked, please file a pull request on our docs repo and link it here: #xxx