From 06b7c8bba0c464a6d5ad27c9f5cd8ef18ff59155 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Wed, 5 Mar 2025 19:47:29 +0100 Subject: [PATCH] Fix fuzzing for imapserver Broken since introducing LoginAttempts. The fuzzing functions didn't get the store.Init() call, and would hang on trying to send to the loginattemptwriter. --- imapserver/fuzz_test.go | 5 +++++ smtpserver/fuzz_test.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/imapserver/fuzz_test.go b/imapserver/fuzz_test.go index dad691a..66353e4 100644 --- a/imapserver/fuzz_test.go +++ b/imapserver/fuzz_test.go @@ -62,8 +62,13 @@ func FuzzServer(f *testing.F) { log := mlog.New("imapserver", nil) mox.ConfigStaticPath = filepath.FromSlash("../testdata/imapserverfuzz/mox.conf") mox.MustLoadConfig(true, false) + store.Close() // May not be open, we ignore error. dataDir := mox.ConfigDirPath(mox.Conf.Static.DataDir) os.RemoveAll(dataDir) + err := store.Init(ctxbg) + if err != nil { + f.Fatalf("store init: %v", err) + } acc, err := store.OpenAccount(log, "mjl", false) if err != nil { f.Fatalf("open account: %v", err) diff --git a/smtpserver/fuzz_test.go b/smtpserver/fuzz_test.go index 1a075a5..f03f710 100644 --- a/smtpserver/fuzz_test.go +++ b/smtpserver/fuzz_test.go @@ -35,8 +35,14 @@ func FuzzServer(f *testing.F) { mox.Context = ctxbg mox.ConfigStaticPath = filepath.FromSlash("../testdata/smtpserverfuzz/mox.conf") mox.MustLoadConfig(true, false) + store.Close() // May not be open, we ignore error. dataDir := mox.ConfigDirPath(mox.Conf.Static.DataDir) os.RemoveAll(dataDir) + err := store.Init(ctxbg) + if err != nil { + f.Fatalf("store init: %v", err) + } + acc, err := store.OpenAccount(log, "mjl", false) if err != nil { f.Fatalf("open account: %v", err)