Debian Codegraph @

debian/patches/fix-nil-checks.patch

raw
1 From 73f201257314631723fe0b9e223960abe7a7ba1f Mon Sep 17 00:00:00 2001
2 From: Terrance <[email protected]>
3 Date: Tue, 4 Aug 2026 18:13:00 +0100
4 Subject: [PATCH] search: fix mbox criteria nil checks
5
6 The mbox search helpers SearchMessage and GetRequiredParts receive a nil
7 SearchCriteria when no filter is active, but don't check for this before
8 trying to access the inner SearchCriteriaPart fields.
9
10 Add further nil checks against the top-level criteria.
11
12 Fixes: d9ff08b05ffe ("search: add option to invert filters/searches")
13 Signed-off-by: Terrance <[email protected]>
14 Acked-by: Robin Jarry <[email protected]>
15 ---
16 worker/lib/search.go | 6 ++++++
17 1 file changed, 6 insertions(+)
18
19 diff --git a/worker/lib/search.go b/worker/lib/search.go
20 index cf53cedddd104b2c2b2a5e9f7f7f6e96f2e85854..97dece9f64c5fbe748812eb12c2b323d0ceb56a5 100644
21 --- a/worker/lib/search.go
22 +++ b/worker/lib/search.go
23 @@ -35,6 +35,9 @@ func Search(messages []rfc822.RawMessage, criteria *types.SearchCriteria) ([]mod
24 func SearchMessage(
25 message rfc822.RawMessage, criteria *types.SearchCriteria, parts MsgParts,
26 ) (bool, error) {
27 + if criteria == nil {
28 + return true, nil
29 + }
30 if criteria.Exclude != nil {
31 excluded, err := searchMessage(message, criteria.Exclude, parts)
32 if err != nil || excluded {
33 @@ -186,6 +189,9 @@ const (
34 // Returns a bitmask of the parts of the message required to be loaded for the
35 // given criteria
36 func GetRequiredParts(criteria *types.SearchCriteria) MsgParts {
37 + if criteria == nil {
38 + return NONE
39 + }
40 return getRequiredParts(criteria.Match) | getRequiredParts(criteria.Exclude)
41 }
42