Skip to content

Commit e9b5e22

Browse files
fjlkaralabe
authored andcommitted
rpc: limit chunked requests (#16343)
1 parent e506d38 commit e9b5e22

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rpc/http.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
169169
// All checks passed, create a codec that reads direct from the request body
170170
// untilEOF and writes the response to w and order the server to process a
171171
// single request.
172-
codec := NewJSONCodec(&httpReadWriteNopCloser{r.Body, w})
172+
body := io.LimitReader(r.Body, maxRequestContentLength)
173+
codec := NewJSONCodec(&httpReadWriteNopCloser{body, w})
173174
defer codec.Close()
174175

175176
w.Header().Set("content-type", contentType)

0 commit comments

Comments
 (0)