From 53419fe8bcaca1efea91b77610fef37bb77ebc86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20I=C3=B1iguez=20Goia?= Date: Wed, 26 Jan 2022 21:12:16 +0100 Subject: [PATCH] rules: fixed leak/panic when parsing/loading lists Rules of type lists [domains, IPs, network ranges] are reloaded whenever a file containing the data changes. One could expect to update these files once or twice a day, but by updating the files continuously it was possible to cause a leak, leading to a crash. --- daemon/rule/operator.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daemon/rule/operator.go b/daemon/rule/operator.go index 503e1ebd..45cbc341 100644 --- a/daemon/rule/operator.go +++ b/daemon/rule/operator.go @@ -233,6 +233,9 @@ func (o *Operator) reListCmp(v interface{}) bool { if o.Sensitive == false { dstHost = strings.ToLower(dstHost) } + o.RLock() + defer o.RUnlock() + for file, re := range o.lists { r := re.(*regexp.Regexp) if r.MatchString(dstHost) {