Repository navigation
[release/11.0] Fix possible overflow in WriteToStream in HostModel - #137383
Merged
Merged
Conversation
`WriteToStream` casts the file length from `long` to `int` before calculating the remaining bytes. For files larger than `int.MaxValue` (2 GiB), this can produce a negative `bytesRequested`, causing the method to exit without reporting an error or copying the complete file. The `int` position counter also cannot represent offsets beyond this limit. This fix uses a `long` position counter and calculates the remaining length using 64-bit arithmetic. It casts the result to `int` only after `Math.Min` caps the requested size to the 16 KiB buffer. fixes #137187
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
|
Hi, the code complete date for 11.0.1 (the December 2026 release) is Monday 16 November. Make sure to merge this PR on that date at the latest, or it won't make it into that release. As a reminder, if this is a product change, you also need Tactics approval before merging this PR (test-only or infra-only changes don't require Tactics approval). Happy to help with the merge if needed! |
JulieLeeMSFT
approved these changes
Nov 21, 2026
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 #137242 to release/11.0
/cc @elinor-fung @HEllRZA
Customer Impact
Issue: #137187
Publishing as single-file produces an empty executable above 2GB. There is no warning/error about the incorrect output.
Regression
Pre-existing bug, but exposed via changes in how the bundler writes out the single-file host in .NET 10.
Testing
Manual
Risk
Low