Skip to content

Decode frames from sliced, direct and read-only buffers - #1513

Open
PHJ2000 wants to merge 1 commit into
TooTallNate:masterfrom
PHJ2000:fix-frame-buffer-copy-offsets
Open

PHJ2000 wants to merge 1 commit into
TooTallNate:masterfrom
PHJ2000:fix-frame-buffer-copy-offsets

Conversation

@PHJ2000

@PHJ2000 PHJ2000 commented Oct 22, 2026

Copy link
Copy Markdown

Description

Read frame payloads and incomplete-frame continuations through relative ByteBuffer operations. The current backing-array copies ignore a sliced input's array offset and cannot read direct or read-only inputs. For example, decoding the slice containing 82 02 0a 0b from a prefixed buffer produces payload 02 0a instead of 0a 0b.

The copies now consume exactly the requested bytes and preserve the input limit. Add a 64-case regression matrix for heap/direct and writable/read-only slices, masked/unmasked frames, empty/short/16-bit/64-bit payload lengths, consecutive frames, and split input. Forty-seven cases fail before the fix; all pass afterward.

Related Issue

Fixes #1512.

Motivation and Context

Valid sliced buffers must not silently corrupt payload bytes, and frame decoding should work with direct and read-only buffers as well as ordinary heap buffers.

How Has This Been Tested?

Temurin 17, Linux x86_64:

  • The frame/extension/protocol/buffer/encoding unit selection passed all 162 tests, including all 64 new cases.
  • mvn -B -ntp -DskipTests package checkstyle:check passed.
  • Tests were run with mvn ... test-compile org.apache.maven.plugins:maven-surefire-plugin:3.5.4:test: the default Surefire 2.17 runner did not discover the Jupiter tests.
  • Full suite: 398 tests, 396 passed. CustomSSLWebSocketServerFactoryTest.testWrapChannel fails with SSLHandshakeException for disabled legacy cipher suites; the same failure reproduces against the original production class. A second full run again had that failure and an intermittent Issue834Test.testNoNewThreads failure; the first run instead had an intermittent Issue997Test SSL callback assertion, which passed in the second run and in the baseline-focused run.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed. (All new tests passed; full-suite limitations described above.)

Signed-off-by: Jaehong Park <105151063+PHJ2000@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 08813b1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Draft_6455 corrupts payloads from sliced buffers and rejects direct/read-only input

1 participant