From 6eff832d0988d05d6c3f41fe1162504537a9eef7 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Thu, 20 Apr 2023 14:58:05 +0200 Subject: [PATCH] fix fuzzing imapserver by not triggering the rate limiter --- imapserver/fuzz_test.go | 5 ++++- smtpserver/fuzz_test.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/imapserver/fuzz_test.go b/imapserver/fuzz_test.go index f0aa398..54c9411 100644 --- a/imapserver/fuzz_test.go +++ b/imapserver/fuzz_test.go @@ -82,7 +82,7 @@ func FuzzServer(f *testing.F) { var fl *os.File if false { - fl, err = os.Create("fuzz.log") + fl, err = os.OpenFile("fuzz.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) if err != nil { f.Fatalf("fuzz log") } @@ -96,6 +96,7 @@ func FuzzServer(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { run := func(cmds []string) { + limitersInit() // Reset rate limiters. serverConn, clientConn := net.Pipe() defer serverConn.Close() @@ -132,6 +133,8 @@ func FuzzServer(f *testing.F) { cid++ } + // Each command brings the connection state one step further. We try the fuzzing + // input for each state. run([]string{}) run([]string{"login mjl@mox.example testtest"}) run([]string{"login mjl@mox.example testtest", "select inbox"}) diff --git a/smtpserver/fuzz_test.go b/smtpserver/fuzz_test.go index 8f6fa5a..17c3f65 100644 --- a/smtpserver/fuzz_test.go +++ b/smtpserver/fuzz_test.go @@ -73,6 +73,7 @@ func FuzzServer(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { run := func(cmds []string) { + limitersInit() // Reset rate limiters. serverConn, clientConn := net.Pipe() defer serverConn.Close() defer clientConn.Close()