[release/v7.6.1] PSStyle: validate background index against BackgroundColorMap#27263
Closed
daxian-dbw wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Backport to release/v7.6.1 of a PSStyle bounds-check fix so background color indices are validated against the background color map length, avoiding incorrect ArgumentOutOfRangeException when validating background colors.
Changes:
- Fix background index bounds validation in
PSStyle.MapColorPairToEscapeSequenceto compare againstBackgroundColorMap.Length.
Comment on lines
+895
to
897
| if (backIndex < 0 || backIndex >= BackgroundColorMap.Length) | ||
| { | ||
| throw new ArgumentOutOfRangeException(paramName: nameof(backgroundColor)); |
There was a problem hiding this comment.
PR description mentions fixing FromAnsiColor, but there is no FromAnsiColor implementation in this branch/repo and the actual fix is in MapColorPairToEscapeSequence. Please update the description to reference the correct method/behavior to avoid confusion during release backport tracking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #27106 to release/v7.6.1
Triggered by @daxian-dbw on behalf of @cuiweixie
Original CL Label: CL-General
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Customer Impact
Fixes
FromAnsiColorincorrectly raisingArgumentOutOfRangeExceptionwhen validating background color index againstForegroundColorMap.Lengthinstead ofBackgroundColorMap.Length. Customers using PSStyle background colors with maps that differ in size would encounter unexpected exceptions.Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Manual code review verified the fix uses the correct map (
BackgroundColorMap) for bounds validation in the background color branch. CI will validate the change.Risk
REQUIRED: Check exactly one box.
Single-line bounds check fix — corrects which map length is used for validation. No behavioral change for valid inputs, and the fix only affects the error path when maps differ in size.