From 6be114f03a12086211234c05a4f7801416488c67 Mon Sep 17 00:00:00 2001 From: Alexander Marx Date: Sat, 17 Oct 2015 19:27:03 +0200 Subject: [PATCH] BUG10941: fix single ip-addresses when no subnet given Some functions when adding a new route where senseless. Now the ip address is checked and in case of a missing / wrong subnetmask an errormessage is raised. The ip address is preserved. ELSE we convert the subnetmask to cidr notation and calculate the network ip correctly. Signed-off-by: Alexander Marx Signed-off-by: Michael Tremer --- html/cgi-bin/routing.cgi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/html/cgi-bin/routing.cgi b/html/cgi-bin/routing.cgi index c460a74e7c..2c60f67cdf 100644 --- a/html/cgi-bin/routing.cgi +++ b/html/cgi-bin/routing.cgi @@ -118,12 +118,16 @@ if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) { } if ($settings{'ACTION'} eq $Lang::tr{'add'}) { - # Convert subnet masks to CIDR notation. - $settings{'IP'} = &General::iporsubtocidr($settings{'IP'}); -# Validate inputs - if (( !&General::validip($settings{'IP'})) and ( !&General::validipandmask($settings{'IP'}))){ + # Validate inputs + if (!&General::validipandmask($settings{'IP'}))){ $errormessage = $Lang::tr{'invalid ip'}." / ".$Lang::tr{'invalid netmask'}; + }else{ + #set networkip if not already correctly defined + my($ip,$cidr) = split(/\//,$settings{'IP'}); + $cidr = &General::iporsubtocidr($cidr); + my $netip=&General::getnetworkip($ip,$cidr); + $settings{'IP'} = "$netip/$cidr"; } if ($settings{'IP'} =~ /^0\.0\.0\.0/){ -- 2.39.2