GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix IndexOutOfBoundsException in StompSubframeDecoder on heartbeat by daguimu · Pull Request #16539 · netty/netty

Conversation

@daguimu

@daguimu daguimu commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Problem

StompSubframeDecoder.skipControlCharacters() reads bytes in an infinite loop without checking if the buffer has readable bytes remaining. When a STOMP heartbeat frame (just a LF byte) arrives, the method consumes the control character and then attempts to read beyond the buffer, causing an IndexOutOfBoundsException.

Root Cause

The skipControlCharacters method has an unconditional buffer.readByte() call inside a for (;;) loop with no buffer.isReadable() guard. When the buffer contains only control characters (heartbeat), all bytes are consumed and the next readByte() fails.

Fix

Add a buffer.isReadable() check before each readByte() call. When the buffer is exhausted (heartbeat-only data), the method returns gracefully and the decoder waits for more data.

Tests Added

  • testHeartbeatOnlyDoesNotThrowException - Single LF heartbeat byte does not cause exception
  • testMultipleHeartbeatsDoNotThrowException - Multiple consecutive LF bytes handled correctly
  • testCarriageReturnLineFeedHeartbeat - CR+LF heartbeat handled correctly
  • testHeartbeatFollowedByFrame - Heartbeat before a real STOMP frame, frame decodes correctly
  • testHeartbeatBetweenFrames - Heartbeat between two frames, both decode correctly
  • testHeartbeatSentSeparatelyThenFrame - Heartbeat in separate write, then frame in second write

Impact

Minimal - only adds a single isReadable() guard. No behavioral change for normal STOMP frames.

Fixes #10678

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
normanmaurer
normanmaurer approved these changes Mar 25, 2026
View reviewed changes
@normanmaurer

normanmaurer commented Mar 25, 2026

Copy link
Copy Markdown
Member

@daguimu did you sign our ICLA yet ? https://netty.io/s/icla

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.2.12.Final milestone Mar 25, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Mar 25, 2026
@daguimu

daguimu commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

@daguimu did you sign our ICLA yet ? https://netty.io/s/icla

Yes, I just signed it! 😊

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daguimu
Fix IndexOutOfBoundsException in StompSubframeDecoder when processing…
4cdc3d8
… heartbeat frames

StompSubframeDecoder.skipControlCharacters() reads bytes in a loop
without checking if the buffer has readable bytes remaining. When a
STOMP heartbeat (just a LF byte) arrives, the method consumes the
control character and then attempts to read beyond the buffer, causing
an IndexOutOfBoundsException.

Add a buffer.isReadable() check before each readByte() call so that
heartbeat-only data is handled gracefully without throwing.

Fixes netty#10678
@daguimu
daguimu force-pushed the fix/stomp-heartbeat-ioobe-10678 branch from 730f619 to 4cdc3d8 Compare March 25, 2026 08:25
@daguimu

daguimu commented Mar 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I've rebased onto the latest 4.1. This PR is ready for merge. Thanks for the review!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added needs-cherry-pick-4.2 This PR should be cherry-picked to 4.2 once merged. and removed needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. labels Mar 25, 2026
@normanmaurer normanmaurer modified the milestones: 4.2.12.Final, 4.1.133.Final Mar 25, 2026
@normanmaurer
normanmaurer merged commit 6f6ac4b into netty:4.1 Mar 25, 2026
18 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Mar 25, 2026

Copy link
Copy Markdown
Member

@daguimu thanks a lot.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

netty-project-bot pushed a commit that referenced this pull request Mar 25, 2026
@daguimu @netty-project-bot
Fix IndexOutOfBoundsException in StompSubframeDecoder on heartbeat (#…
46816cf
…16539)

## Problem

`StompSubframeDecoder.skipControlCharacters()` reads bytes in an
infinite loop without checking if the buffer has readable bytes
remaining. When a STOMP heartbeat frame (just a LF byte) arrives, the
method consumes the control character and then attempts to read beyond
the buffer, causing an IndexOutOfBoundsException.

## Root Cause

The `skipControlCharacters` method has an unconditional
`buffer.readByte()` call inside a `for (;;)` loop with no
`buffer.isReadable()` guard. When the buffer contains only control
characters (heartbeat), all bytes are consumed and the next `readByte()`
fails.

## Fix

Add a `buffer.isReadable()` check before each `readByte()` call. When
the buffer is exhausted (heartbeat-only data), the method returns
gracefully and the decoder waits for more data.

## Tests Added

- `testHeartbeatOnlyDoesNotThrowException` - Single LF heartbeat byte
does not cause exception
- `testMultipleHeartbeatsDoNotThrowException` - Multiple consecutive LF
bytes handled correctly
- `testCarriageReturnLineFeedHeartbeat` - CR+LF heartbeat handled
correctly
- `testHeartbeatFollowedByFrame` - Heartbeat before a real STOMP frame,
frame decodes correctly
- `testHeartbeatBetweenFrames` - Heartbeat between two frames, both
decode correctly
- `testHeartbeatSentSeparatelyThenFrame` - Heartbeat in separate write,
then frame in second write

## Impact

Minimal - only adds a single `isReadable()` guard. No behavioral change
for normal STOMP frames.

Fixes #10678

(cherry picked from commit 6f6ac4b)
@netty-project-bot

netty-project-bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.2: #16543

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Mar 25, 2026
Auto-port 4.2: Fix IndexOutOfBoundsException in StompSubframeDecoder on heartbeat #16543
Merged
@netty-project-bot

netty-project-bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-4.2 This PR should be cherry-picked to 4.2 once merged. label Mar 25, 2026
chrisvest pushed a commit to chrisvest/netty that referenced this pull request Mar 25, 2026
@daguimu @chrisvest
Fix IndexOutOfBoundsException in StompSubframeDecoder on heartbeat (n…
d32484b
…etty#16539)

## Problem

`StompSubframeDecoder.skipControlCharacters()` reads bytes in an
infinite loop without checking if the buffer has readable bytes
remaining. When a STOMP heartbeat frame (just a LF byte) arrives, the
method consumes the control character and then attempts to read beyond
the buffer, causing an IndexOutOfBoundsException.

## Root Cause

The `skipControlCharacters` method has an unconditional
`buffer.readByte()` call inside a `for (;;)` loop with no
`buffer.isReadable()` guard. When the buffer contains only control
characters (heartbeat), all bytes are consumed and the next `readByte()`
fails.

## Fix

Add a `buffer.isReadable()` check before each `readByte()` call. When
the buffer is exhausted (heartbeat-only data), the method returns
gracefully and the decoder waits for more data.

## Tests Added

- `testHeartbeatOnlyDoesNotThrowException` - Single LF heartbeat byte
does not cause exception
- `testMultipleHeartbeatsDoNotThrowException` - Multiple consecutive LF
bytes handled correctly
- `testCarriageReturnLineFeedHeartbeat` - CR+LF heartbeat handled
correctly
- `testHeartbeatFollowedByFrame` - Heartbeat before a real STOMP frame,
frame decodes correctly
- `testHeartbeatBetweenFrames` - Heartbeat between two frames, both
decode correctly
- `testHeartbeatSentSeparatelyThenFrame` - Heartbeat in separate write,
then frame in second write

## Impact

Minimal - only adds a single `isReadable()` guard. No behavioral change
for normal STOMP frames.

Fixes netty#10678

(cherry picked from commit 6f6ac4b)
@chrisvest chrisvest mentioned this pull request Mar 25, 2026
5.0 port: Fix IndexOutOfBoundsException in StompSubframeDecoder on heartbeat (#16539) #16552
Merged
@chrisvest

chrisvest commented Mar 25, 2026

Copy link
Copy Markdown
Member

5.0 port: #16552

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest chrisvest removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Mar 25, 2026
chrisvest added a commit that referenced this pull request Mar 27, 2026
@chrisvest @daguimu
5.0 port: Fix IndexOutOfBoundsException in StompSubframeDecoder on he…
28db032
…artbeat (#16539) (#16552)

5.0 port of #16539

The code is already correct in the 5.0 branch, but it can't hurt to
bring over the tests.

---

## Problem

`StompSubframeDecoder.skipControlCharacters()` reads bytes in an
infinite loop without checking if the buffer has readable bytes
remaining. When a STOMP heartbeat frame (just a LF byte) arrives, the
method consumes the control character and then attempts to read beyond
the buffer, causing an IndexOutOfBoundsException.

## Root Cause

The `skipControlCharacters` method has an unconditional
`buffer.readByte()` call inside a `for (;;)` loop with no
`buffer.isReadable()` guard. When the buffer contains only control
characters (heartbeat), all bytes are consumed and the next `readByte()`
fails.

## Fix

Add a `buffer.isReadable()` check before each `readByte()` call. When
the buffer is exhausted (heartbeat-only data), the method returns
gracefully and the decoder waits for more data.

## Tests Added

- `testHeartbeatOnlyDoesNotThrowException` - Single LF heartbeat byte
does not cause exception
- `testMultipleHeartbeatsDoNotThrowException` - Multiple consecutive LF
bytes handled correctly
- `testCarriageReturnLineFeedHeartbeat` - CR+LF heartbeat handled
correctly
- `testHeartbeatFollowedByFrame` - Heartbeat before a real STOMP frame,
frame decodes correctly
- `testHeartbeatBetweenFrames` - Heartbeat between two frames, both
decode correctly
- `testHeartbeatSentSeparatelyThenFrame` - Heartbeat in separate write,
then frame in second write

## Impact

Minimal - only adds a single `isReadable()` guard. No behavioral change
for normal STOMP frames.

Fixes #10678

(cherry picked from commit 6f6ac4b)

Co-authored-by: Guimu <[email protected]>
normanmaurer pushed a commit that referenced this pull request Mar 27, 2026
@netty-project-bot @daguimu
Auto-port 4.2: Fix IndexOutOfBoundsException in StompSubframeDecoder …
eeb5674
…on heartbeat (#16543)

Auto-port of #16539 to 4.2
Cherry-picked commit: 6f6ac4b

---
## Problem

`StompSubframeDecoder.skipControlCharacters()` reads bytes in an
infinite loop without checking if the buffer has readable bytes
remaining. When a STOMP heartbeat frame (just a LF byte) arrives, the
method consumes the control character and then attempts to read beyond
the buffer, causing an IndexOutOfBoundsException.

## Root Cause

The `skipControlCharacters` method has an unconditional
`buffer.readByte()` call inside a `for (;;)` loop with no
`buffer.isReadable()` guard. When the buffer contains only control
characters (heartbeat), all bytes are consumed and the next `readByte()`
fails.

## Fix

Add a `buffer.isReadable()` check before each `readByte()` call. When
the buffer is exhausted (heartbeat-only data), the method returns
gracefully and the decoder waits for more data.

## Tests Added

- `testHeartbeatOnlyDoesNotThrowException` - Single LF heartbeat byte
does not cause exception
- `testMultipleHeartbeatsDoNotThrowException` - Multiple consecutive LF
bytes handled correctly
- `testCarriageReturnLineFeedHeartbeat` - CR+LF heartbeat handled
correctly
- `testHeartbeatFollowedByFrame` - Heartbeat before a real STOMP frame,
frame decodes correctly
- `testHeartbeatBetweenFrames` - Heartbeat between two frames, both
decode correctly
- `testHeartbeatSentSeparatelyThenFrame` - Heartbeat in separate write,
then frame in second write

## Impact

Minimal - only adds a single `isReadable()` guard. No behavioral change
for normal STOMP frames.

Fixes #10678

Co-authored-by: Guimu <[email protected]>
@normanmaurer normanmaurer mentioned this pull request Sep 22, 2026
suspend race fix #17588
Closed
@normanmaurer normanmaurer mentioned this pull request Oct 20, 2026
fix iouring zerocopy iov overwrite #17936
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.1.133.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@daguimu @normanmaurer @netty-project-bot @chrisvest
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.