From e480d64bc5eb7a9accaad93b8845df1bf8bbb2f3 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Mon, 4 Mar 2013 09:08:06 -0300 Subject: [PATCH] Fix validation of conflict between interface ip address and static routes. Fixes #2852 --- usr/local/www/interfaces.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 0be890b908..5279a98559 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -556,10 +556,12 @@ if ($_POST['apply']) { $input_errors[] = gettext("This IPv4 address is being used by another interface or VIP."); foreach ($staticroutes as $route_subnet) { - if (ip_in_subnet($_POST['ipaddr'], $route_subnet)) { + list($network, $subnet) = explode("/", $route_subnet); + if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) { $input_errors[] = gettext("This IPv4 address conflicts with a Static Route."); break; } + unset($network, $subnet); } } } @@ -571,10 +573,12 @@ if ($_POST['apply']) { $input_errors[] = gettext("This IPv6 address is being used by another interface or VIP."); foreach ($staticroutes as $route_subnet) { - if (ip_in_subnet($_POST['ipaddrv6'], $route_subnet)) { + list($network, $subnet) = explode("/", $route_subnet); + if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) { $input_errors[] = gettext("This IPv6 address conflicts with a Static Route."); break; } + unset($network, $subnet); } } }