diff options
Diffstat (limited to 'src/mime/multipart/formdata.go')
-rw-r--r-- | src/mime/multipart/formdata.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mime/multipart/formdata.go b/src/mime/multipart/formdata.go index 4eb3101294..fca5f9e15f 100644 --- a/src/mime/multipart/formdata.go +++ b/src/mime/multipart/formdata.go @@ -7,9 +7,8 @@ package multipart import ( "bytes" "errors" - "fmt" "io" - "io/ioutil" + "math" "net/textproto" "os" ) @@ -43,7 +42,11 @@ 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 { - return nil, fmt.Errorf("multipart: integer overflow from maxMemory(%d) + 10MiB for non-file parts", maxMemory) + if maxMemory < 0 { + maxValueBytes = 0 + } else { + maxValueBytes = math.MaxInt64 + } } for { p, err := r.NextPart() @@ -87,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 } |