mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-23 11:33:37 +08:00
fix: limit request body size in Plain binding
This commit is contained in:
parent
0d0009ed1f
commit
6cfbe5a1e8
@ -16,10 +16,13 @@ func (plainBinding) Name() string {
|
||||
}
|
||||
|
||||
func (plainBinding) Bind(req *http.Request, obj any) error {
|
||||
all, err := io.ReadAll(req.Body)
|
||||
all, err := io.ReadAll(io.LimitReader(req.Body, DefaultMaxBodySize+1))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(all) > DefaultMaxBodySize {
|
||||
return http.ErrBodyReadAfterClose
|
||||
}
|
||||
|
||||
return decodePlain(all, obj)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user