mirror of
https://github.com/golang/go
synced 2024-11-24 13:00:15 -07:00
net/http: fix nil body causing ParseMultipartForm to panic
ParseMultipartForm relies on a valid multipartReader, if the request body is nil, the multipartReader should return an error. This way ParseMultipartForm can return an error instead of causing mr.ReadForm(maxMemory) to panic Fixes #48206 Change-Id: Ief906f2340c7ab29cacbd5f56892117202a0b911 Reviewed-on: https://go-review.googlesource.com/c/go/+/384454 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
96567fb3cc
commit
eca0d44cec
@ -480,6 +480,9 @@ func (r *Request) multipartReader(allowMixed bool) (*multipart.Reader, error) {
|
||||
if v == "" {
|
||||
return nil, ErrNotMultipart
|
||||
}
|
||||
if r.Body == nil {
|
||||
return nil, errors.New("missing form body")
|
||||
}
|
||||
d, params, err := mime.ParseMediaType(v)
|
||||
if err != nil || !(d == "multipart/form-data" || allowMixed && d == "multipart/mixed") {
|
||||
return nil, ErrNotMultipart
|
||||
|
Loading…
Reference in New Issue
Block a user