Skip to content
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

[v14] snowflake/http: Limit Decompressed Request to 10MB #33764

Merged
merged 2 commits into from Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/srv/db/snowflake/http.go
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/gravitational/trace"

"github.com/gravitational/teleport"
"github.com/gravitational/teleport/lib/utils"
)

func writeResponse(resp *http.Response, newResp []byte) (*bytes.Buffer, error) {
Expand Down Expand Up @@ -69,7 +70,7 @@ func copyRequest(ctx context.Context, req *http.Request, body io.Reader) (*http.
func readRequestBody(req *http.Request) ([]byte, error) {
defer req.Body.Close()

body, err := io.ReadAll(io.LimitReader(req.Body, teleport.MaxHTTPRequestSize))
body, err := utils.ReadAtMost(req.Body, teleport.MaxHTTPRequestSize)
if err != nil {
return nil, trace.Wrap(err)
}
Expand All @@ -80,7 +81,7 @@ func readRequestBody(req *http.Request) ([]byte, error) {
func readResponseBody(resp *http.Response) ([]byte, error) {
defer resp.Body.Close()

body, err := io.ReadAll(io.LimitReader(resp.Body, teleport.MaxHTTPRequestSize))
body, err := utils.ReadAtMost(resp.Body, teleport.MaxHTTPRequestSize)
if err != nil {
return nil, trace.Wrap(err)
}
Expand All @@ -107,7 +108,7 @@ func maybeReadGzip(headers *http.Header, body []byte) ([]byte, error) {
}
defer bodyGZ.Close()

body, err = io.ReadAll(bodyGZ)
body, err = utils.ReadAtMost(bodyGZ, teleport.MaxHTTPRequestSize)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down