[prev in list] [next in list] [prev in thread] [next in thread]
List: ipfire-development
Subject: [PATCH] Cleanup2017: make network_equal more robust
From: Alexander Marx <alexander.marx () ipfire ! org>
Date: 2017-06-26 10:52:01
Message-ID: 1498474321-14745-1-git-send-email-alexander.marx () ipfire ! org
[Download RAW message or body]
Michael fixed this in a telephone session
---
config/cfgroot/network-functions.pl | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl
index 66f1ed5..41632c3 100644
--- a/config/cfgroot/network-functions.pl
+++ b/config/cfgroot/network-functions.pl
@@ -108,14 +108,22 @@ sub network_equal {
my $network1 = shift;
my $network2 = shift;
- my $bin1 = &network2bin($network1);
- my $bin2 = &network2bin($network2);
+ my @bin1 = &network2bin($network1);
+ if (scalar @bin1 ne 2) {
+ return undef;
+ }
- if ($bin1 eq $bin2) {
- return 1;
+ my @bin2 = &network2bin($network2);
+ if (scalar @bin2 ne 2) {
+ return undef;
}
- return 0;
+ my $address1 = $bin1[0];
+ my $netmask1 = $bin1[1];
+ my $address2 = $bin2[0];
+ my $netmask2 = $bin2[1];
+
+ return (($address1 eq $address2) && ($netmask1 eq $netmask2));
}
# Takes a network in either a.b.c.d/a.b.c.d or a.b.c.d/e notation
--
2.7.4
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic