From 4c326e8f6cee5c6737d10e23095e8d6e7383bc68 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Wed, 21 Feb 2024 06:02:19 +0100 Subject: [PATCH] Limit memory for fuzz testing CIFuzz has low memory limits that we keep hitting without there being an issue. --- fuzz_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fuzz_test.go b/fuzz_test.go index e07f1a06a7..532c052f99 100644 --- a/fuzz_test.go +++ b/fuzz_test.go @@ -43,8 +43,9 @@ 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) f.Fuzz(func(t *testing.T, body []byte, max int) { - // Don't do bodies bigger than 10kb. - max %= (10 * 1024) + if len(body) > 10*1024 || max > 10*1024 { + return + } var res Response @@ -58,8 +59,9 @@ 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) f.Fuzz(func(t *testing.T, body []byte, max int) { - // Don't do bodies bigger than 10kb. - max %= (10 * 1024) + if len(body) > 10*1024 || max > 10*1024 { + return + } var req Request