Fix flawed termination condition check in HttpPostRequestEncoder…#14799
Merged
normanmaurer merged 2 commits intonetty:4.1from Feb 27, 2025
Merged
Fix flawed termination condition check in HttpPostRequestEncoder…#14799normanmaurer merged 2 commits intonetty:4.1from
normanmaurer merged 2 commits intonetty:4.1from
Conversation
…#encodeNextChunkUrlEncoded(int) for current InterfaceHttpData
…deNextChunkUrlEncoded(int) for current InterfaceHttpData
Contributor
Author
|
@normanmaurer PTAL |
Member
|
@yawkat can you have a look maybe ? |
yawkat
approved these changes
Feb 26, 2025
Contributor
|
LGTM |
chrisvest
approved these changes
Feb 26, 2025
Member
|
@LinShunKang did you sign our icla ? https://netty.io/s/icla ? |
Contributor
Author
Yes, I have signed it. |
normanmaurer
pushed a commit
that referenced
this pull request
Feb 27, 2025
…4799) …#encodeNextChunkUrlEncoded(int) for current InterfaceHttpData Motivation: I am using `HttpPostRequestEncoder` to encode a few request parameters, but I read **infinite** chunks when the following conditions are met: 1. The number of POST request parameters is greater than or equal to 2. 2. The length of the first request parameter value > `DefaultHttpDataFactory#minSize`. 3. The length of the first request parameter key + the length of the request parameter value + 2 = N * `HttpPostBodyUtil#chunkSize` This issue can be reproduced by modifying the [length](https://github.com/netty/netty/blob/34011b5f02c52122eccd36ce7cc69502a514d0f1/codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoderTest.java#L454) variable in the [HttpPostRequestEncoderTest#testEncodeChunkedContent()](https://github.com/netty/netty/blob/34011b5f02c52122eccd36ce7cc69502a514d0f1/codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoderTest.java#L450) method to `HttpPostBodyUtil.chunkSize * 3 - 4 - 2`. Normally, this test method should complete quickly, but when the length variable is set to `HttpPostBodyUtil.chunkSize * 3 - 4 - 2`, it will never finish. Modification: 1. Enhance the logic of determining whether the current `InterfaceHttpData` has been fully read. Result: Fix flawed termination condition check. --------- Co-authored-by: LinShunKang <linshunkang@kanzhun.com>
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.
…#encodeNextChunkUrlEncoded(int) for current InterfaceHttpData
Motivation:
I am using
HttpPostRequestEncoderto encode a few request parameters, but I read infinite chunks when the following conditions are met:DefaultHttpDataFactory#minSize.HttpPostBodyUtil#chunkSizeThis issue can be reproduced by modifying the length variable in the HttpPostRequestEncoderTest#testEncodeChunkedContent() method to
HttpPostBodyUtil.chunkSize * 3 - 4 - 2. Normally, this test method should complete quickly, but when the length variable is set toHttpPostBodyUtil.chunkSize * 3 - 4 - 2, it will never finish.Modification:
InterfaceHttpDatahas been fully read.Result:
Fix flawed termination condition check.