add some protections to ACLs and an error log, following #686
This commit is contained in:
@@ -101,7 +101,11 @@ sub check_acl {
|
|||||||
return 0 if !defined $real_ip
|
return 0 if !defined $real_ip
|
||||||
or blessed $real_ip; # class we do not understand
|
or blessed $real_ip; # class we do not understand
|
||||||
|
|
||||||
$config = [$config] if ref [] ne ref $config;
|
$config = [$config] if ref '' eq ref $config;
|
||||||
|
if (ref [] ne ref $config) {
|
||||||
|
error "error: acl is not a single item or list (cannot compare to $real_ip)";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
my $all = (scalar grep {$_ eq 'op:and'} @$config);
|
my $all = (scalar grep {$_ eq 'op:and'} @$config);
|
||||||
|
|
||||||
# common case of using plain IP in ACL, so string compare for speed
|
# common case of using plain IP in ACL, so string compare for speed
|
||||||
@@ -201,6 +205,9 @@ sub check_acl {
|
|||||||
next INLIST;
|
next INLIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# could be something in error, and IP/host is only option left
|
||||||
|
next INLIST if ref $item;
|
||||||
|
|
||||||
my $ip = NetAddr::IP::Lite->new($item)
|
my $ip = NetAddr::IP::Lite->new($item)
|
||||||
or next INLIST;
|
or next INLIST;
|
||||||
next INLIST if $ip->bits != $addr->bits and not $all;
|
next INLIST if $ip->bits != $addr->bits and not $all;
|
||||||
|
|||||||
Reference in New Issue
Block a user