mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-23 11:33:37 +08:00
fix: limit request body size in BSON binding
This commit is contained in:
parent
6010158337
commit
3b3f352fa6
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user