Skip to content

Guard against integer overflow on server-supplied message lengths#220

Merged
SeanTAllen merged 1 commit intomainfrom
fix-message-size-wrap
Apr 14, 2026
Merged

Guard against integer overflow on server-supplied message lengths#220
SeanTAllen merged 1 commit intomainfrom
fix-message-size-wrap

Conversation

@SeanTAllen
Copy link
Copy Markdown
Member

Companion to #211. On 32-bit USize targets a server-declared length near U32.max could wrap payload_size + 4 + 1 to a small value, slipping a bogus zero-payload acknowledgement past the buffer-size check. The fix is the same flavor as #215 — use partial arithmetic at the site so the wrap surfaces as a protocol violation directly.

CI runs lp64, so the new test's ilp32 branch can't be exercised here; the counterfactual was walked through analytically and is documented in the test's docstring.

Closes #217.

Closes #217.

Companion to #211. USize addition wraps just like USize subtraction does.
On 32-bit USize targets a server-declared length near `U32.max` could
wrap `payload_size + 4 + 1` to a small value and slip a bogus zero-
payload acknowledgement past the buffer-size check. Same flavor of bug
as #211, same flavor of fix — validate the arithmetic so wrap surfaces
as a protocol violation directly.

CI runs lp64, so the regression can only be reasoned about analytically
here; the ilp32 test branch is retained for whenever a 32-bit Pony
target lands.
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Apr 14, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Apr 14, 2026
@SeanTAllen SeanTAllen merged commit 7a0efe8 into main Apr 14, 2026
11 checks passed
@SeanTAllen SeanTAllen deleted the fix-message-size-wrap branch April 14, 2026 23:31
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Apr 14, 2026
github-actions Bot pushed a commit that referenced this pull request Apr 14, 2026
github-actions Bot pushed a commit that referenced this pull request Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

message_size can wrap on 32-bit USize targets when server declares a huge length

2 participants