fix(draft): cap default maxFrameSize and enforce before allocation - #1509
Open
arimu1 wants to merge 1 commit into
Open
fix(draft): cap default maxFrameSize and enforce before allocation#1509arimu1 wants to merge 1 commit into
arimu1 wants to merge 1 commit into
Conversation
|
Use a 16 MiB default frame payload limit instead of Integer.MAX_VALUE so declared lengths cannot drive multi-gigabyte allocations. Draft_6455 checkAlloc now rejects sizes above maxFrameSize before buffering. Fixes TooTallNate#1507
arimu1
force-pushed
the
fix/1507-default-max-frame-size
branch
from
September 12, 2026 13:24
52e5599 to
c411ff7
Compare
marci4
approved these changes
Sep 13, 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.
Description
Draft_6455.DEFAULT_MAX_FRAME_SIZE(16 MiB) and use it for constructors that previously defaulted toInteger.MAX_VALUE.checkAllocinDraft_6455so declared buffer sizes abovemaxFrameSizeraiseLimitExceededExceptionbeforeByteBuffer.allocate.Related Issue
Fixes #1507
Motivation and Context
With an uncapped default, the RFC 6455 decoder could honor a peer’s declared payload length and attempt a matching allocation. A conservative default limit and an allocation guard align default server/client drafts with bounded memory use; callers that need larger frames can still pass an explicit
inputMaxFrameSize.How Has This Been Tested?
mvn test -Dtest=Draft_6455Test(Java 21, Temurin)getMaxFrameSize()and that a modest oversized declared length (header only) is rejected without large allocationsTypes of changes
Checklist: