mirror of
https://gitlab.com/shorewall/code.git
synced 2025-05-02 15:14:38 +02:00
Better fix for '-0x...' handling
This commit is contained in:
parent
846af27ebf
commit
e465fea86a
@ -735,11 +735,13 @@ sub assert( $ ) {
|
|||||||
# Convert value to decimal number
|
# Convert value to decimal number
|
||||||
#
|
#
|
||||||
sub numeric_value ( $ ) {
|
sub numeric_value ( $ ) {
|
||||||
no warnings;
|
|
||||||
my $mark = lc $_[0];
|
my $mark = lc $_[0];
|
||||||
return undef unless $mark =~ /^-?(0x[a-f0-9]+|0[0-7]*|[1-9]\d*)$/;
|
my $negative = ( $mark =~ s/^-// );
|
||||||
$mark =~ /^0/ ? oct $mark : $mark;
|
return undef unless $mark =~ /^(0x[a-f0-9]+|0[0-7]*|[1-9]\d*)$/;
|
||||||
|
no warnings;
|
||||||
|
$mark = ( $mark =~ /^0/ ? oct $mark : $mark );
|
||||||
use warnings;
|
use warnings;
|
||||||
|
$negative ? - $mark : $mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub numeric_value1 ( $ ) {
|
sub numeric_value1 ( $ ) {
|
||||||
|
@ -316,14 +316,12 @@ sub process_tc_rule( $$$$$$$$$$$$ ) {
|
|||||||
|
|
||||||
if ( defined $m1 && $m1 ne '' ) {
|
if ( defined $m1 && $m1 ne '' ) {
|
||||||
$val = numeric_value ($m1);
|
$val = numeric_value ($m1);
|
||||||
fatal_error "Invalid Mask ($m1)" if $m1 =~ /^-0x/;
|
|
||||||
fatal_error "Invalid Mask ($m1)" unless defined $val && $val && $val <= 0xffffffff;
|
fatal_error "Invalid Mask ($m1)" unless defined $val && $val && $val <= 0xffffffff;
|
||||||
$mask1 = $m1;
|
$mask1 = $m1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( defined $m2 && $m2 ne '' ) {
|
if ( defined $m2 && $m2 ne '' ) {
|
||||||
$val = numeric_value ($m2);
|
$val = numeric_value ($m2);
|
||||||
fatal_error "Invalid Mask ($m2)" if $m2 =~ /^-0x/;
|
|
||||||
fatal_error "Invalid Mask ($m2)" unless defined $val && $val <= 0xffffffff;
|
fatal_error "Invalid Mask ($m2)" unless defined $val && $val <= 0xffffffff;
|
||||||
$mask2 = $m2;
|
$mask2 = $m2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user