Fix network-functions net membership check

Message ID 20191223185412.13338-1-ipfr@tfitzgeorge.me.uk
State Superseded
Headers show
Series Fix network-functions net membership check | expand

Commit Message

Tim FitzGeorge Dec. 23, 2019, 6:54 p.m. UTC
Replace textual comparison of two number with arithmetic in
ip_address_in_Network().

Fixes: 12263
Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
---
 config/cfgroot/network-functions.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bernhard Bitsch Dec. 23, 2019, 9:27 p.m. UTC | #1
Hi,

> Gesendet: Montag, 23. Dezember 2019 um 19:54 Uhr
> Von: "Tim FitzGeorge" <ipfr@tfitzgeorge.me.uk>
> An: development@lists.ipfire.org
> Betreff: [PATCH] Fix network-functions net membership check
>
> Replace textual comparison of two number with arithmetic in
> ip_address_in_Network().
>
> Fixes: 12263
> Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
> ---
>  config/cfgroot/network-functions.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl
> index 8649d0502..589044c2a 100644
> --- a/config/cfgroot/network-functions.pl
> +++ b/config/cfgroot/network-functions.pl
> @@ -295,7 +295,7 @@ sub ip_address_in_network($$) {
>  	# Find end address
>  	my $broadcast_bin = $network_bin ^ (~$netmask_bin % 2 ** 32);
>
> -	return (($address_bin ge $network_bin) && ($address_bin le $broadcast_bin));
> +	return (($address_bin => $network_bin) && ($address_bin <= $broadcast_bin));

should work if you change '=>' to '>='

>  }
>
>  sub setup_upstream_proxy() {
> --
> 2.16.4
>
>

Bernhard

Patch

diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl
index 8649d0502..589044c2a 100644
--- a/config/cfgroot/network-functions.pl
+++ b/config/cfgroot/network-functions.pl
@@ -295,7 +295,7 @@  sub ip_address_in_network($$) {
 	# Find end address
 	my $broadcast_bin = $network_bin ^ (~$netmask_bin % 2 ** 32);
 
-	return (($address_bin ge $network_bin) && ($address_bin le $broadcast_bin));
+	return (($address_bin => $network_bin) && ($address_bin <= $broadcast_bin));
 }
 
 sub setup_upstream_proxy() {