Firewall: BUG 10528 - allow subnets greater than /8

This commit is contained in:
Alexander Marx
2014-04-23 14:19:34 +02:00
committed by Michael Tremer
parent bb8895e259
commit 7490b22e9d

View File

@@ -353,7 +353,7 @@ sub iporsubtodec
} }
#Subnet already in decimal and valid? #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 ))) { 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 (&General::cidrtosub($i) eq $mask){
if ($full == 0){return $mask;}else{ if ($full == 0){return $mask;}else{
return $net."/".$mask; return $net."/".$mask;
@@ -362,7 +362,7 @@ sub iporsubtodec
} }
} }
#Subnet in binary format? #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{ if($full == 0){ return &General::cidrtosub($mask);}else{
return $net."/".&General::cidrtosub($mask); return $net."/".&General::cidrtosub($mask);
} }
@@ -389,7 +389,7 @@ sub iporsubtocidr
} }
#Subnet in decimal and valid? #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 ))) { 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 (&General::cidrtosub($i) eq $mask){
if ($full == 0){return &General::subtocidr($mask);}else{ if ($full == 0){return &General::subtocidr($mask);}else{
return $net."/".&General::subtocidr($mask); return $net."/".&General::subtocidr($mask);
@@ -398,7 +398,7 @@ sub iporsubtocidr
} }
} }
#Subnet already in binary format? #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{ if($full == 0){ return $mask;}else{
return $net."/".$mask; 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 ))) { 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? #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 ))) { 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){ if (&General::cidrtosub($i) eq $ccdsubnet){
return 1; return 1;
} }
} }
#Subnet already in binary format? #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; return 1;
}else{ }else{
return 0; return 0;