aboutsummaryrefslogtreecommitdiff
path: root/src/mime/multipart/formdata.go
diff options
context:
space:
mode:
authorKatie Hockman <katie@golang.org>2020-12-14 10:03:05 -0500
committerKatie Hockman <katie@golang.org>2020-12-14 10:06:13 -0500
commit0345ede87ee12698988973884cfc0fd3d499dffd (patch)
tree7123cff141ee5661208d2f5f437b8f5252ac7f6a /src/mime/multipart/formdata.go
parent4651d6b267818b0e0d128a5443289717c4bb8cbc (diff)
parent0a02371b0576964e81c3b40d328db9a3ef3b031b (diff)
downloadgo-0345ede87ee12698988973884cfc0fd3d499dffd.tar.xz
[dev.fuzz] all: merge master into dev.fuzz
Change-Id: I5d8c8329ccc9d747bd81ade6b1cb7cb8ae2e94b2
Diffstat (limited to 'src/mime/multipart/formdata.go')
-rw-r--r--src/mime/multipart/formdata.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mime/multipart/formdata.go b/src/mime/multipart/formdata.go
index 832d0ad693..fca5f9e15f 100644
--- a/src/mime/multipart/formdata.go
+++ b/src/mime/multipart/formdata.go
@@ -8,7 +8,7 @@ import (
"bytes"
"errors"
"io"
- "io/ioutil"
+ "math"
"net/textproto"
"os"
)
@@ -41,6 +41,13 @@ func (r *Reader) readForm(maxMemory int64) (_ *Form, err error) {
// Reserve an additional 10 MB for non-file parts.
maxValueBytes := maxMemory + int64(10<<20)
+ if maxValueBytes <= 0 {
+ if maxMemory < 0 {
+ maxValueBytes = 0
+ } else {
+ maxValueBytes = math.MaxInt64
+ }
+ }
for {
p, err := r.NextPart()
if err == io.EOF {
@@ -83,7 +90,7 @@ func (r *Reader) readForm(maxMemory int64) (_ *Form, err error) {
}
if n > maxMemory {
// too big, write to disk and flush buffer
- file, err := ioutil.TempFile("", "multipart-")
+ file, err := os.CreateTemp("", "multipart-")
if err != nil {
return nil, err
}