diff --git a/binding/bson.go b/binding/bson.go index 464890f0..09eccc73 100644 --- a/binding/bson.go +++ b/binding/bson.go @@ -18,8 +18,11 @@ func (bsonBinding) Name() string { } func (b bsonBinding) 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 { + if len(buf) > DefaultMaxBodySize { + return http.ErrBodyReadAfterClose + } err = b.BindBody(buf, obj) } return err