diff --git a/binding/protobuf.go b/binding/protobuf.go index 259ae8e7..0e522722 100644 --- a/binding/protobuf.go +++ b/binding/protobuf.go @@ -19,10 +19,13 @@ func (protobufBinding) Name() string { } func (b protobufBinding) Bind(req *http.Request, obj any) error { - buf, err := io.ReadAll(req.Body) + buf, err := io.ReadAll(io.LimitReader(req.Body, DefaultMaxBodySize+1)) if err != nil { return err } + if len(buf) > DefaultMaxBodySize { + return http.ErrBodyReadAfterClose + } return b.BindBody(buf, obj) }