diff options
author | mathew <meta@pobox.com> | 2022-07-29 11:58:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-29 18:58:52 +0200 |
commit | 42f83c60cf9f2ca6944dea1c1e6898fd2b646b93 (patch) | |
tree | 781013a9e2e52ad26d433e8a46c7771cf5c323f6 /http.go | |
parent | Introduce FS.CompressRoot (#1331) (diff) | |
download | fasthttp-42f83c60cf9f2ca6944dea1c1e6898fd2b646b93.tar.gz fasthttp-42f83c60cf9f2ca6944dea1c1e6898fd2b646b93.tar.bz2 fasthttp-42f83c60cf9f2ca6944dea1c1e6898fd2b646b93.zip |
Prevent overflow and panic on large HTTP responses (#1351)
Diffstat (limited to 'http.go')
-rw-r--r-- | http.go | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -8,6 +8,7 @@ import ( "errors" "fmt" "io" + "math" "mime/multipart" "net" "os" @@ -2278,5 +2279,10 @@ func round2(n int) int { x |= x >> 8 x |= x >> 16 + // Make sure we don't return 0 due to overflow, even on 32 bit systems + if x >= uint32(math.MaxInt32) { + return math.MaxInt32 + } + return int(x + 1) } |