Improve validation for data fragments for PSRP frame headers - #27871
Merged
Travis Plunk (TravisEz13) merged 1 commit intoAug 20, 2026
Conversation
Anam Navied (anamnavi)
requested review from
Travis Plunk (TravisEz13) and
Dongbo Wang (daxian-dbw)
as code owners
August 20, 2026 17:35
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens fragment receive/defragment logic in ReceiveDataCollection.ProcessRawData by enforcing the configured maximum received object size based on the fragment header as soon as it’s available (even when the fragment payload has not fully arrived yet), while avoiding prematurely mutating the running size total.
Changes:
- Computes a temporary
totalSizeToBeReceivedand validates it against_maxReceivedObjectSizebefore the “enough bytes received” check, so oversize frames are rejected early. - Updates
_totalReceivedObjectSizeSoFaronly after the complete fragment is present, preventing partial fragments from inflating the running total. - Simplifies the overflow catch to
OverflowExceptionwhile retaining the same behavior on arithmetic overflow.
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Travis Plunk (TravisEz13)
approved these changes
Aug 20, 2026
Travis Plunk (TravisEz13)
merged commit Aug 20, 2026
68437b2
into
PowerShell:master
44 of 47 checks passed
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.
This pull request refines the logic for handling received data fragments in the
ProcessRawDatamethod ofPriorityCollection.cs. The main improvements are to the enforcement of the maximum object size limit and the order of checks, ensuring more accurate and robust processing of incoming data. These changes make the data processing logic more robust, especially in scenarios where large or incomplete data fragments are received.Key changes to object size limit enforcement and data processing:
_maxReceivedObjectSize) is now performed before confirming that the complete data fragment has been received, using a new temporary variable (totalSizeToBeReceived) to avoid prematurely updating the running total. The running total (_totalReceivedObjectSizeSoFar) is only updated after the entire fragment has been received._pendingDataStream.Length < totalLengthOfFragment) has been moved after the object size limit check, ensuring that size limits are enforced even if the fragment is incomplete.OverflowExceptiondirectly (instead ofSystem.OverflowException).PR Summary
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header