Skip to content

[release/10.0] Fix possible overflow in WriteToStream in HostModel - #137384

Merged
JulieLeeMSFT merged 1 commit into
release/10.0from
backport/pr-137242-to-release/10.0
Nov 21, 2026
Merged

JulieLeeMSFT merged 1 commit into
release/10.0from
backport/pr-137242-to-release/10.0

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #137242 to release/10.0

/cc @elinor-fung @HEllRZA

Customer Impact

  • Customer reported
  • Found internally

Issue: #137187

Publishing as single-file produces an empty executable above 2GB. There is no warning/error about the incorrect output.

Regression

  • Yes
  • No

Pre-existing bug, but exposed via changes in how the bundler writes out the single-file host in .NET 10.

Testing

Manual

Risk

Low

`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

Copy link
Copy Markdown
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.

@elinor-fung elinor-fung added this to the 10.0.x milestone Nov 11, 2026
@elinor-fung elinor-fung added the Servicing-consider Issue for next servicing release review label Nov 11, 2026
@elinor-fung elinor-fung changed the title [release/10.0] Fix possible overflow in WriteToStream [release/10.0] Fix possible overflow in WriteToStream in HostModel Nov 11, 2026
@ViveliDuCh

Copy link
Copy Markdown
Member

Hi,

the code complete date for 10.0.16 (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 JulieLeeMSFT added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Nov 21, 2026
@JulieLeeMSFT
JulieLeeMSFT merged commit 6ee61ac into release/10.0 Nov 21, 2026
105 of 113 checks passed
@JulieLeeMSFT
JulieLeeMSFT deleted the backport/pr-137242-to-release/10.0 branch November 21, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Host Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants