[PR #15235] [MERGED] Prevent crash when VTParameters::subspan is out of range #30520

Open
opened 2026-01-31 09:41:20 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/15235
Author: @j4james
Created: 4/25/2023
Status: Merged
Merged: 4/25/2023
Merged by: @zadjii-msft

Base: mainHead: fix-subspan-crash


📝 Commits (2)

  • 882adae Fix crash when VTParameters subspan is out of range.
  • f965e39 Add subspan unit test.

📊 Changes

2 files changed (+38 additions, -1 deletions)

View changed files

📝 src/terminal/adapter/DispatchTypes.hpp (+1 -1)
📝 src/terminal/parser/ut_parser/StateMachineTest.cpp (+37 -0)

📄 Description

Summary of the Pull Request

There are certain escape sequences that use the VTParameters::subspan
method to access a subsection of the provided parameter list. When the
parameter list is empty, that subspan call can end up using an offset
that is out of range, which causes the terminal to crash. This PR stops
that from happening by clamping the offset so it's in range.

References and Relevant Issues

This bug effected the DECCARA and DECRARA operations introduced in
PR #14285, and the DECPS operation introduced in PR #13208.

Validation Steps Performed

I've manually confirmed that the sequences mentioned above are no longer
crashing when executed with an empty parameter list, and I've added a
little unit test that checks VTParameters::subspan method is returning
the expected results when passed an offset that is out of range.

PR Checklist


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/15235 **Author:** [@j4james](https://github.com/j4james) **Created:** 4/25/2023 **Status:** ✅ Merged **Merged:** 4/25/2023 **Merged by:** [@zadjii-msft](https://github.com/zadjii-msft) **Base:** `main` ← **Head:** `fix-subspan-crash` --- ### 📝 Commits (2) - [`882adae`](https://github.com/microsoft/terminal/commit/882adae15f1bd38a9e0ff1edc58798c47f1ff2a7) Fix crash when VTParameters subspan is out of range. - [`f965e39`](https://github.com/microsoft/terminal/commit/f965e39baeacfdc053bd30cea8e9fa406bbcbdaa) Add subspan unit test. ### 📊 Changes **2 files changed** (+38 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/terminal/adapter/DispatchTypes.hpp` (+1 -1) 📝 `src/terminal/parser/ut_parser/StateMachineTest.cpp` (+37 -0) </details> ### 📄 Description ## Summary of the Pull Request There are certain escape sequences that use the `VTParameters::subspan` method to access a subsection of the provided parameter list. When the parameter list is empty, that `subspan` call can end up using an offset that is out of range, which causes the terminal to crash. This PR stops that from happening by clamping the offset so it's in range. ## References and Relevant Issues This bug effected the `DECCARA` and `DECRARA` operations introduced in PR #14285, and the `DECPS` operation introduced in PR #13208. ## Validation Steps Performed I've manually confirmed that the sequences mentioned above are no longer crashing when executed with an empty parameter list, and I've added a little unit test that checks `VTParameters::subspan` method is returning the expected results when passed an offset that is out of range. ## PR Checklist - [x] Closes #15234 - [x] Tests added/passed - [ ] Documentation updated - [ ] Schema updated (if necessary) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:41:20 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30520