GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — Fix IndexOutOfBoundsException in StompSubframeDecoder on heartbeat by daguimu · Pull Request #16539 · netty/netty Conversation
Contributor
Problem
Root CauseThe FixAdd a Tests Added
ImpactMinimal - only adds a single Fixes #10678
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
normanmaurer
approved these changes
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. … 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
force-pushed
the
fix/stomp-heartbeat-ioobe-10678
branch
from
730f619 to
4cdc3d8
Compare
|
There was an error while loading. Please reload this page.
|
I've rebased onto the latest 4.1. This PR is ready for merge. Thanks for the review! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@daguimu thanks a lot. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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)
|
Auto-port PR for 4.2: #16543 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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)
|
5.0 port: #16552 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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]>
…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]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.