From 01d61d15493fe7ff4ed8198dd8abdf57b97eefc6 Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Sun, 20 Sep 2015 13:03:34 +0200 Subject: [PATCH] network_functions.pl: fix ip_address_in_network for x86_64 calculation of last address must use only 32bit of inverted netmask. Signed-off-by: Arne Fitzenreiter --- config/cfgroot/network-functions.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl index 9dd752d5e6..cb4ca3dd88 100644 --- a/config/cfgroot/network-functions.pl +++ b/config/cfgroot/network-functions.pl @@ -256,7 +256,7 @@ sub ip_address_in_network($$) { my ($network_bin, $netmask_bin) = &network2bin($network); # Find end address - my $broadcast_bin = $network_bin ^ ~$netmask_bin; + my $broadcast_bin = $network_bin ^ (~$netmask_bin % 2 ** 32); return (($address_bin ge $network_bin) && ($address_bin le $broadcast_bin)); } @@ -342,6 +342,9 @@ sub testsuite() { $result = &ip_address_in_network("10.0.1.4", "10.0.0.0/8"); assert($result); + $result = &ip_address_in_network("192.168.30.11", "192.168.30.0/255.255.255.0"); + assert($result); + return 0; } -- 2.39.5