]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
BUG10941: fix single ip-addresses when no subnet given
authorAlexander Marx <alexander.marx@ipfire.org>
Sat, 17 Oct 2015 17:27:03 +0000 (19:27 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 18 Oct 2015 18:19:51 +0000 (19:19 +0100)
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 <alexander.marx@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
html/cgi-bin/routing.cgi

index c460a74e7ca1ab56d4d2dd44f8ecc9d69f9df6c2..2c60f67cdfc4e7982ea7d5c60ad0d446eb17b24c 100644 (file)
@@ -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/){