Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crash when VTParameters::subspan is out of range #15235

Merged
merged 2 commits into from
Apr 25, 2023

Conversation

j4james
Copy link
Collaborator

@j4james j4james commented Apr 25, 2023

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

@microsoft-github-policy-service microsoft-github-policy-service bot added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Apr 25, 2023
@j4james j4james marked this pull request as ready for review April 25, 2023 21:39
@zadjii-msft zadjii-msft merged commit e413a41 into microsoft:main Apr 25, 2023
DHowett pushed a commit that referenced this pull request Apr 25, 2023
## 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)

(cherry picked from commit e413a41)
Service-Card-Id: 89001985
Service-Version: 1.17
@zadjii-msft
Copy link
Member

Any chance this also stealth fixed #12378?

@j4james
Copy link
Collaborator Author

j4james commented Apr 27, 2023

Any chance this also stealth fixed #12378?

No, but it looks like it was fixed a while ago. Technically the original crash was fixed by PR #12432, although it was still throwing an internal exception at that point. That exception was later fixed by PR #14093 I think. So the bottom line is you can probably close that issue now.

@zadjii-msft
Copy link
Member

Wow thanks for the diligence!

@j4james j4james deleted the fix-subspan-crash branch May 30, 2023 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Certain sequences with default parameters can trigger a crash
3 participants