mirror of
https://github.com/golang/go.git
synced 2025-05-29 03:11:26 +00:00
http: put a limit on POST size
R=rsc CC=golang-dev https://golang.org/cl/4432076
This commit is contained in:
parent
6e71e1ca76
commit
ec3fe2a5b6
@ -596,13 +596,17 @@ func (r *Request) ParseForm() (err os.Error) {
|
|||||||
ct := r.Header.Get("Content-Type")
|
ct := r.Header.Get("Content-Type")
|
||||||
switch strings.Split(ct, ";", 2)[0] {
|
switch strings.Split(ct, ";", 2)[0] {
|
||||||
case "text/plain", "application/x-www-form-urlencoded", "":
|
case "text/plain", "application/x-www-form-urlencoded", "":
|
||||||
b, e := ioutil.ReadAll(r.Body)
|
const maxFormSize = int64(10 << 20) // 10 MB is a lot of text.
|
||||||
|
b, e := ioutil.ReadAll(io.LimitReader(r.Body, maxFormSize+1))
|
||||||
if e != nil {
|
if e != nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = e
|
err = e
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if int64(len(b)) > maxFormSize {
|
||||||
|
return os.NewError("http: POST too large")
|
||||||
|
}
|
||||||
e = parseQuery(r.Form, string(b))
|
e = parseQuery(r.Form, string(b))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = e
|
err = e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user