Fix LENGTH handling (again)

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-03-23 15:40:48 -07:00
parent 398c843643
commit f4ed4109c6

View File

@ -4244,10 +4244,26 @@ sub do_length( $ ) {
require_capability( 'LENGTH_MATCH' , 'A Non-empty LENGTH' , 's' );
fatal_error "Invalid LENGTH ($length)" unless $length =~/^(\d+)(:(\d+))?$/;
my ( $max, $min );
if ( supplied $2 ) {
fatal_error "First length must be < second length" unless $1 < $3;
if ( $length =~ /^\d+$/ ) {
fatal_error "Invalid LENGTH ($length)" unless $length < 65536;
$min = $max = $1;
} else {
if ( $length =~ /^:(\d+)$/ ) {
$min = 0;
$max = $1;
} elsif ( $length =~ /^(\d+):$/ ) {
$min = $1;
$max = 65535;
} elsif ( $length =~ /^(\d+):(\d+)$/ ) {
$min = $1;
$max = $2;
} else {
fatal_error "Invalid LENGTH ($length)";
}
fatal_error "First length must be < second length" unless $min < $max;
}
"-m length --length $length ";