From c205a253b4f469cc53b45b6bff830ffd0dc5a12a Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Tue, 16 Jan 2024 05:06:58 +0100 Subject: Put a limit on the max body size for fuzzing --- fuzz_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fuzz_test.go b/fuzz_test.go index 72fa1a2..827e776 100644 --- a/fuzz_test.go +++ b/fuzz_test.go @@ -54,6 +54,10 @@ func FuzzResponseReadLimitBody(f *testing.F) { 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) { + if max > 10*1024*1024 { // Skip limits higher than 10MB. + return + } + _ = res.ReadLimitBody(bufio.NewReader(bytes.NewReader(body)), max) w := bytes.Buffer{} _, _ = res.WriteTo(&w) @@ -67,6 +71,10 @@ func FuzzRequestReadLimitBody(f *testing.F) { 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) { + if max > 10*1024*1024 { // Skip limits higher than 10MB. + return + } + _ = req.ReadLimitBody(bufio.NewReader(bytes.NewReader(body)), max) w := bytes.Buffer{} _, _ = req.WriteTo(&w) -- cgit v1.2.3