…n of ReadForm
Reader.ReadForm is documented as storing "up to maxMemory bytes + 10MB"
in memory. Parsed forms can consume substantially more memory than
this limit, since ReadForm does not account for map entry overhead
and MIME headers.
In addition, while the amount of disk memory consumed by ReadForm can
be constrained by limiting the size of the parsed input, ReadForm will
create one temporary file per form part stored on disk, potentially
consuming a large number of inodes.
Update ReadForm's memory accounting to include part names,
MIME headers, and map entry overhead.
Update ReadForm to store all on-disk file parts in a single
Files returned by FileHeader.Open are documented as having a concrete
type of *os.File when a file is stored on disk. The change to use a
single temporary file for all parts means that this is no longer the
case when a form contains more than a single file part stored on disk.
The previous behavior of storing each file part in a separate disk
file may be reenabled with GODEBUG=multipartfiles=distinct.
Update Reader.NextPart and Reader.NextRawPart to set a 10MiB cap
on the size of MIME headers.
Thanks to Jakob Ackermann (@das7pad) for reporting this issue.
Reviewed-by: Julie Qiu <email@example.com>
TryBot-Result: Security TryBots <firstname.lastname@example.org>
Reviewed-by: Roland Shoemaker <email@example.com>
Run-TryBot: Damien Neil <firstname.lastname@example.org>
(cherry picked from commit ed4664330edcd91b24914c9371c377c132dbce8c)
Reviewed-by: Tatiana Bradley <email@example.com>
Run-TryBot: Roland Shoemaker <firstname.lastname@example.org>
Reviewed-by: Damien Neil <email@example.com>
TryBot-Result: Gopher Robot <firstname.lastname@example.org>
Reviewed-by: Than McIntosh <email@example.com>
Run-TryBot: Michael Pratt <firstname.lastname@example.org>
Auto-Submit: Michael Pratt <email@example.com>
@rolandshoemaker requested issue #58006 to be considered for backport to the next 1.19 minor release.
The text was updated successfully, but these errors were encountered: