Firewall: BUG 10528 - allow subnets greater than /8
authorAlexander Marx <alexander.marx@ipfire.org>
Wed, 23 Apr 2014 12:19:34 +0000 (14:19 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Apr 2014 13:08:47 +0000 (15:08 +0200)
config/cfgroot/general-functions.pl

index adfba54..271dc41 100644 (file)
@@ -353,7 +353,7 @@ sub iporsubtodec
        }
        #Subnet already in decimal and valid?
        if ($mask=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1<=255  && $2<=$1 && $3<=$2  && $4<=$3 )))       {
-               for (my $i=8;$i<=32;$i++){
+               for (my $i=0;$i<=32;$i++){
                        if (&General::cidrtosub($i) eq $mask){
                                if ($full == 0){return $mask;}else{
                                                         return $net."/".$mask;
@@ -362,7 +362,7 @@ sub iporsubtodec
                }       
        }
        #Subnet in binary format?
-       if ($mask=~/^(\d{1,2})$/ && (($1<=32 && $1>=8))){
+       if ($mask=~/^(\d{1,2})$/ && (($1<=32 && $1>=0))){
                        if($full == 0){ return &General::cidrtosub($mask);}else{
                                                 return $net."/".&General::cidrtosub($mask);
                        }
@@ -389,7 +389,7 @@ sub iporsubtocidr
        }
        #Subnet in decimal and valid?
        if ($mask=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1<=255  && $2<=$1 && $3<=$2  && $4<=$3 )))       {
-               for (my $i=8;$i<=32;$i++){
+               for (my $i=0;$i<=32;$i++){
                        if (&General::cidrtosub($i) eq $mask){
                                if ($full == 0){return &General::subtocidr($mask);}else{
                                                         return $net."/".&General::subtocidr($mask);
@@ -398,7 +398,7 @@ sub iporsubtocidr
                }       
        }
        #Subnet already in binary format?
-       if ($mask=~/^(\d{1,2})$/ && (($1<=32 && $1>=8))){
+       if ($mask=~/^(\d{1,2})$/ && (($1<=32 && $1>=0))){
                        if($full == 0){ return $mask;}else{
                                                 return $net."/".$mask;
                        }
@@ -488,13 +488,13 @@ sub validipandmask
        if ($ccdip=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1>0 && $1<=255 && $2>=0 && $2<=255 && $3>=0 && $3<=255 && $4<=255 ))) {
                #Subnet in decimal and valid?
                if ($ccdsubnet=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1<=255  && $2<=$1 && $3<=$2  && $4<=$3 )))  {
-                       for (my $i=8;$i<=32;$i++){
+                       for (my $i=0;$i<=32;$i++){
                                if (&General::cidrtosub($i) eq $ccdsubnet){
                                        return 1;
                                }
-                       }       
+                       }
                #Subnet already in binary format?
-               }elsif ($ccdsubnet=~/^(\d{1,2})$/ && (($1<=32 && $1>=8))){
+               }elsif ($ccdsubnet=~/^(\d{1,2})$/ && (($1<=32 && $1>=0))){
                        return 1;
                }else{
                        return 0;