aboutsummaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorGravatar mathew <meta@pobox.com> 2022-07-29 11:58:52 -0500
committerGravatar GitHub <noreply@github.com> 2022-07-29 18:58:52 +0200
commit42f83c60cf9f2ca6944dea1c1e6898fd2b646b93 (patch)
tree781013a9e2e52ad26d433e8a46c7771cf5c323f6 /http.go
parentIntroduce FS.CompressRoot (#1331) (diff)
downloadfasthttp-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.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/http.go b/http.go
index 0cf1bfe..cfeeac5 100644
--- a/http.go
+++ b/http.go
@@ -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)
}