Clean up range expansion

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@8325 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2008-03-21 17:42:15 +00:00
parent d33f6583ad
commit a672e03a82

View File

@ -361,23 +361,23 @@ sub expand_port_range( $$ ) {
if ( $range =~ /^(.*):(.*)$/ ) {
my ( $first, $last ) = ( $1, $2);
my @result;
fatal_error "Invalid port range ($range)" unless $first ne '' or $last ne '';
$first = 0 if $first eq '';
$last = 65535 if $last eq '';
my @result;
( $first , $last ) = ( validate_port( $proto, $first ) , validate_port( $proto, $last ) );
my $l = $last + 1;
$last++;
while ( $first <= $last ) {
while ( $first < $last ) {
my $mask = 0xffff;
my $y = 2;
my $z = 1;
while ( ( $first % $y ) == 0 && ( $first + $y ) <= $l ) {
while ( ( $first % $y ) == 0 && ( $first + $y ) <= $last ) {
$mask <<= 1;
$z = $y;
$y <<= 1;