aboutsummaryrefslogtreecommitdiff
path: root/http_test.go
diff options
context:
space:
mode:
authorGravatar nickajacks1 <128185314+nickajacks1@users.noreply.github.com> 2024-01-05 21:39:23 -0800
committerGravatar GitHub <noreply@github.com> 2024-01-06 13:39:23 +0800
commitf0905a14d1117335c08b7eb586e409eef24846fc (patch)
tree1aac56c01248ba86df27bae805faf3a1480ea712 /http_test.go
parenttest(expvarhandler): fix failure when using -count to run more than once (#1688) (diff)
downloadfasthttp-f0905a14d1117335c08b7eb586e409eef24846fc.tar.gz
fasthttp-f0905a14d1117335c08b7eb586e409eef24846fc.tar.bz2
fasthttp-f0905a14d1117335c08b7eb586e409eef24846fc.zip
test: migrate remaining fuzzit tests to go 1.18 fuzzing (#1687)
Diffstat (limited to 'http_test.go')
-rw-r--r--http_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/http_test.go b/http_test.go
index 098990a..57f0220 100644
--- a/http_test.go
+++ b/http_test.go
@@ -1700,6 +1700,32 @@ func testRequestReadLimitBodySuccess(t *testing.T, s string, maxBodySize int) {
}
}
+func FuzzResponseReadLimitBody(f *testing.F) {
+ res := AcquireResponse()
+ defer ReleaseResponse(res)
+
+ f.Add([]byte("HTTP/1.1 200 OK\r\nContent-Type: aa\r\nContent-Length: 10\r\n\r\n9876543210"), 1024*1024)
+
+ f.Fuzz(func(t *testing.T, body []byte, max int) {
+ _ = res.ReadLimitBody(bufio.NewReader(bytes.NewReader(body)), max)
+ w := bytes.Buffer{}
+ _, _ = res.WriteTo(&w)
+ })
+}
+
+func FuzzRequestReadLimitBody(f *testing.F) {
+ req := AcquireRequest()
+ defer ReleaseRequest(req)
+
+ f.Add([]byte("POST /a HTTP/1.1\r\nHost: a.com\r\nTransfer-Encoding: chunked\r\nContent-Type: aa\r\n\r\n6\r\nfoobar\r\n3\r\nbaz\r\n0\r\nfoobar\r\n\r\n"), 1024*1024)
+
+ f.Fuzz(func(t *testing.T, body []byte, max int) {
+ _ = req.ReadLimitBody(bufio.NewReader(bytes.NewReader(body)), max)
+ w := bytes.Buffer{}
+ _, _ = req.WriteTo(&w)
+ })
+}
+
func TestRequestString(t *testing.T) {
t.Parallel()