ip lists: check the list size before parsing the IP

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2025-01-23 08:07:33 +01:00
parent b686da5e56
commit 83ee977746

View File

@@ -418,6 +418,10 @@ func (l *IPList) IsListed(ip, protocol string) (bool, int, error) {
l.mu.RLock()
defer l.mu.RUnlock()
if l.Ranges.Len() == 0 {
return false, 0, nil
}
parsedIP := net.ParseIP(ip)
if parsedIP == nil {
return false, 0, fmt.Errorf("invalid IP %s", ip)