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 — Length field based frame decoder can be optimized by AbcCreatorDeep · Pull Request #12173 · netty/netty Conversation
|
|
Man, is this PR possible to get accepted? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
sure... Lets wait for the CI to finish |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@NickleHuang can you please sign our ICLA: https://netty.io/s/icla |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Done |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@NickleHuang thanks... merged! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: LengthFieldBasedFrameDecoder.decode(ChannelHandlerContext ctx, ByteBuf in) methodcan be optimized -So we keep frameLengthInt in instance variable to avoid unnecessary calculations . Modification: Add an instance variable to avoid unnecessary calculations Result: Fixes #12171. Co-authored-by: Norman Maurer <[email protected]>
Motivation: LengthFieldBasedFrameDecoder.decode(ChannelHandlerContext ctx, ByteBuf in) methodcan be optimized -So we keep frameLengthInt in instance variable to avoid unnecessary calculations . Modification: Add an instance variable to avoid unnecessary calculations Result: Fixes netty#12171. Co-authored-by: Norman Maurer <[email protected]>
Motivation: LengthFieldBasedFrameDecoder.decode(ChannelHandlerContext ctx, ByteBuf in) methodcan be optimized -So we keep frameLengthInt in instance variable to avoid unnecessary calculations . Modification: Add an instance variable to avoid unnecessary calculations Result: Fixes netty#12171. Co-authored-by: Norman Maurer <[email protected]>
…an initialBytesToStrip (#17606) Motivation: When the adjusted frame length is less than `initialBytesToStrip`, `LengthFieldBasedFrameDecoder` throws a `CorruptedFrameException` without resetting `frameLengthInt`. Every following `decode(...)` call then skips reading the length field of the next frame, sees the same short frame length again, and throws again. `frameLength` is `0` in those calls, so no bytes are skipped either. One malformed frame therefore makes every later frame on the connection fail (`Adjusted frame length (0) is less than initialBytesToStrip: ...`). The same happens on the first malformed frame if its length field and its content arrive in separate reads. All the other error paths of the decoder reset their state and go on with the next frame. This regressed in #12173, which cached the frame length in `frameLengthInt` but only reset it on the success path. Modification: - Reset `frameLengthInt` before failing, and skip the frame using `frameLengthInt` instead of the local `frameLength`, which is `0` when the length field was read by an earlier call. - Add two tests: the malformed frame in one read, and its length field and content in separate reads. Both fail without the change (with the exception above on the following valid frame) and pass with it. Result: The decoder fails the malformed frame and then decodes the following frames again. `codec-base` tests: 352, 0 failures.
…e is shorter than initialBytesToStrip (#17621) Auto-port of #17606 to 4.1 Cherry-picked commit: c784721 --- Motivation: When the adjusted frame length is less than `initialBytesToStrip`, `LengthFieldBasedFrameDecoder` throws a `CorruptedFrameException` without resetting `frameLengthInt`. Every following `decode(...)` call then skips reading the length field of the next frame, sees the same short frame length again, and throws again. `frameLength` is `0` in those calls, so no bytes are skipped either. One malformed frame therefore makes every later frame on the connection fail (`Adjusted frame length (0) is less than initialBytesToStrip: ...`). The same happens on the first malformed frame if its length field and its content arrive in separate reads. All the other error paths of the decoder reset their state and go on with the next frame. This regressed in #12173, which cached the frame length in `frameLengthInt` but only reset it on the success path. Modification: - Reset `frameLengthInt` before failing, and skip the frame using `frameLengthInt` instead of the local `frameLength`, which is `0` when the length field was read by an earlier call. - Add two tests: the malformed frame in one read, and its length field and content in separate reads. Both fail without the change (with the exception above on the following valid frame) and pass with it. Result: The decoder fails the malformed frame and then decodes the following frames again. `codec-base` tests: 352, 0 failures. Co-authored-by: allthingssecurity <[email protected]>
…e is shorter than initialBytesToStrip (#17622) Auto-port of #17606 to 5.0 Cherry-picked commit: c784721 --- Motivation: When the adjusted frame length is less than `initialBytesToStrip`, `LengthFieldBasedFrameDecoder` throws a `CorruptedFrameException` without resetting `frameLengthInt`. Every following `decode(...)` call then skips reading the length field of the next frame, sees the same short frame length again, and throws again. `frameLength` is `0` in those calls, so no bytes are skipped either. One malformed frame therefore makes every later frame on the connection fail (`Adjusted frame length (0) is less than initialBytesToStrip: ...`). The same happens on the first malformed frame if its length field and its content arrive in separate reads. All the other error paths of the decoder reset their state and go on with the next frame. This regressed in #12173, which cached the frame length in `frameLengthInt` but only reset it on the success path. Modification: - Reset `frameLengthInt` before failing, and skip the frame using `frameLengthInt` instead of the local `frameLength`, which is `0` when the length field was read by an earlier call. - Add two tests: the malformed frame in one read, and its length field and content in separate reads. Both fail without the change (with the exception above on the following valid frame) and pass with it. Result: The decoder fails the malformed frame and then decodes the following frames again. `codec-base` tests: 352, 0 failures. --------- Co-authored-by: allthingssecurity <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
…e is shorter than initialBytesToStrip (netty#17621) Auto-port of netty#17606 to 4.1 Cherry-picked commit: c784721 --- Motivation: When the adjusted frame length is less than `initialBytesToStrip`, `LengthFieldBasedFrameDecoder` throws a `CorruptedFrameException` without resetting `frameLengthInt`. Every following `decode(...)` call then skips reading the length field of the next frame, sees the same short frame length again, and throws again. `frameLength` is `0` in those calls, so no bytes are skipped either. One malformed frame therefore makes every later frame on the connection fail (`Adjusted frame length (0) is less than initialBytesToStrip: ...`). The same happens on the first malformed frame if its length field and its content arrive in separate reads. All the other error paths of the decoder reset their state and go on with the next frame. This regressed in netty#12173, which cached the frame length in `frameLengthInt` but only reset it on the success path. Modification: - Reset `frameLengthInt` before failing, and skip the frame using `frameLengthInt` instead of the local `frameLength`, which is `0` when the length field was read by an earlier call. - Add two tests: the malformed frame in one read, and its length field and content in separate reads. Both fail without the change (with the exception above on the following valid frame) and pass with it. Result: The decoder fails the malformed frame and then decodes the following frames again. `codec-base` tests: 352, 0 failures. Co-authored-by: allthingssecurity <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
LengthFieldBasedFrameDecoder Class Can be optimized
There was an error while loading. Please reload this page.