From patchwork Wed Nov 8 00:17:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Marx X-Patchwork-Id: 1518 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 460F060DC6 for ; Tue, 7 Nov 2017 14:32:43 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 9074B353C; Tue, 7 Nov 2017 14:32:42 +0100 (CET) Received: from localhost.localdomain (business-90-187-3-157.pool2.vodafone-ip.de [90.187.3.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 69E54353C; Tue, 7 Nov 2017 14:17:35 +0100 (CET) From: Alexander Marx To: development@lists.ipfire.org Subject: [PATCH] BUG11466: Fix network_equal function Date: Tue, 7 Nov 2017 14:17:27 +0100 Message-Id: <1510060647-12424-1-git-send-email-alexander.marx@ipfire.org> X-Mailer: git-send-email 2.7.4 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" The network_equal function only tested the subnet addresses of two given networks which lead to errormessages saying "This is the green network" The fix tests netwok and subnet IP's to fix this --- config/cfgroot/network-functions.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl index 93b8190..25f9af1 100644 --- a/config/cfgroot/network-functions.pl +++ b/config/cfgroot/network-functions.pl @@ -108,10 +108,10 @@ sub network_equal { my $network1 = shift; my $network2 = shift; - my $bin1 = &network2bin($network1); - my $bin2 = &network2bin($network2); + my @bin1 = &network2bin($network1); + my @bin2 = &network2bin($network2); - if ($bin1 eq $bin2) { + if ($bin1[0] eq $bin2[0] && $bin1[1] eq $bin2[1]) { return 1; } @@ -457,7 +457,7 @@ sub testsuite() { assert(!$result); $result = &network_equal("192.168.0.1/24", "192.168.0.XXX/24"); - assert($result); + assert(!$result); $result = &ip_address_in_network("10.0.1.4", "10.0.0.0/8"); assert($result);