From: Arne Fitzenreiter Date: Sun, 20 Sep 2015 11:03:34 +0000 (+0200) Subject: network_functions.pl: fix ip_address_in_network for x86_64 X-Git-Tag: v2.17-core94~3^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=01d61d15493fe7ff4ed8198dd8abdf57b97eefc6;p=people%2Fpmueller%2Fipfire-2.x.git 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 --- 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; }