-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StreamRequestBody shouldn't read more data than actual need. #1819
StreamRequestBody shouldn't read more data than actual need. #1819
Conversation
8363ef6
to
066cf08
Compare
Line 2286 in 1fb3453
Here, contentLength is guaranteed to be greater than or equal to 0 because the ContinueReadBodyStream function has already filtered out cases where contentLength is less than 0. It is assumed that a negative Content-Length value other than -1 should not be processed: Line 1372 in 1fb3453
Below code will also handle cases where maxBodySize is less than contentLength. Line 2295 in 1fb3453
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the fix looks good. But the new file needs to be formatted. And http.go needs some more newlines:
http.go:2287: line is 147 characters (lll)
A fixed-length pre-read function should be used here; otherwise, it may read content beyond the request body into areas outside of the br buffer.
http.go:2288: line is 160 characters (lll)
This could affect the handling of the next request in the br buffer, if there is one. The original two branches can be handled with this single branch.
The StreamRequestBody feature on the server side should not read content that does not belong to the current request body.This is more logical and consistent with the result of not using the StreamRequestBody feature.Fixes: valyala#1816.
066cf08
to
4ccdb7c
Compare
Co-authored-by: Erik Dubbelboer <[email protected]>
Co-authored-by: Erik Dubbelboer <[email protected]>
@erikdubbelboer May I ask what tools you use to lint the fasthttp codebase? |
@newacorn you can see that here: fasthttp/.github/workflows/lint.yml Lines 26 to 28 in 38a91cd
|
Thanks! |
The StreamRequestBody feature on the server side should not read content that does not belong to the current request body.This is more logical and consistent with the result of not using the StreamRequestBody feature.
Fixes: #1816.
The reason for addressing this issue is that the Read method of requestStream assumes it should only read up to the Content-Length number of bytes.