network: is_ip_in_cidr: correctly handle the CIDR being a singleton range

i.e.  is_ip_in_cidr('127.0.0.1', '127.0.0.1/32', 4) should return 1;

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2021-05-10 14:18:13 +02:00 committed by Thomas Lamprecht
parent 06c1c13f1c
commit 123c310474

View File

@ -592,7 +592,9 @@ sub is_ip_in_cidr {
my $ip_obj = Net::IP->new($ip, $version);
return undef if !$ip_obj;
return $cidr_obj->overlaps($ip_obj) == $Net::IP::IP_B_IN_A_OVERLAP;
my $overlap = $cidr_obj->overlaps($ip_obj);
return $overlap == $Net::IP::IP_B_IN_A_OVERLAP || $overlap == $Net::IP::IP_IDENTICAL;
}