Improve editing of port numbers/service names

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2017-06-25 07:44:23 -07:00
parent 71d50e0217
commit 4122021344
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10

View File

@ -851,8 +851,15 @@ sub validate_port( $$ ) {
my $value; my $value;
if ( $port =~ /^(\d+)$/ || $port =~ /^0x/ ) { if ( $port =~ /^(\d+)$/ || $port =~ /^0x/ ) {
$port = numeric_value $port; $value = numeric_value $port;
return $port if defined $port && $port && $port <= 65535;
if ( defined $value ) {
if ( $value && $value <= 65535 ) {
return $value;
} else {
$value = undef;
}
}
} elsif ( $port =~ /^%(.*)/ ) { } elsif ( $port =~ /^%(.*)/ ) {
$value = record_runtime_port( $1 ); $value = record_runtime_port( $1 );
} else { } else {
@ -891,13 +898,13 @@ sub validate_portpair( $$ ) {
$what = 'port range'; $what = 'port range';
unless ($ports[0] =~ /^\$/ || $ports[1] =~ /^\$/ ) { unless ($ports[0] =~ /^\$/ || $ports[1] =~ /^\$/ ) {
fatal_error "Invalid port range ($portpair)" unless $ports[0] < $ports[1]; fatal_error "Invalid port range ($_[1])" unless $ports[0] < $ports[1];
} }
} else { } else {
$what = 'port'; $what = 'port';
} }
fatal_error "Using a $what ( $portpair ) requires PROTO TCP, UDP, UDPLITE, SCTP or DCCP" unless fatal_error "Using a $what ( $_[1] ) requires PROTO TCP, UDP, UDPLITE, SCTP or DCCP" unless
defined $protonum && ( $protonum == TCP || defined $protonum && ( $protonum == TCP ||
$protonum == UDP || $protonum == UDP ||
$protonum == UDPLITE || $protonum == UDPLITE ||