forked from extern/shorewall_code
Normalize hex numbers before using them in string comparisons
This commit is contained in:
parent
e66d491f11
commit
222c5dbf46
@ -812,14 +812,6 @@ sub numeric_value1 ( $ ) {
|
||||
use warnings;
|
||||
}
|
||||
|
||||
sub normalize_hex( $ ) {
|
||||
my $val = shift;
|
||||
|
||||
$val =~ s/^0x//;
|
||||
$val =~ s/^0// while length $val > 1;
|
||||
$val;
|
||||
}
|
||||
|
||||
sub hex_value( $ ) {
|
||||
my $val = lc $_[0];
|
||||
$val =~ s/^0x//;
|
||||
@ -829,6 +821,17 @@ sub hex_value( $ ) {
|
||||
use warnings;
|
||||
}
|
||||
|
||||
#
|
||||
# Strip off leading 0x and superfluous leading zeros from a hex number
|
||||
#
|
||||
sub normalize_hex( $ ) {
|
||||
my $val = shift;
|
||||
|
||||
$val =~ s/^0x//;
|
||||
$val =~ s/^0// while $val =~ /^0/ && length $val > 1;
|
||||
$val;
|
||||
}
|
||||
|
||||
#
|
||||
# Return the argument expressed in Hex
|
||||
#
|
||||
|
@ -255,7 +255,7 @@ sub process_tc_rule( ) {
|
||||
fatal_error "Invalid MARK ($originalmark)" unless $mark =~ /^([0-9]+|0x[0-9a-f]+)$/ and $designator =~ /^([0-9]+|0x[0-9a-f]+)$/;
|
||||
|
||||
if ( $config{TC_ENABLED} eq 'Internal' || $config{TC_ENABLED} eq 'Shared' ) {
|
||||
$originalmark =~ s/0x//g;
|
||||
$originalmark = join( ':', normalize_hex( $mark ), normalize_hex( $designator ) );
|
||||
fatal_error "Unknown Class ($originalmark)}" unless ( $device = $classids{$originalmark} );
|
||||
fatal_error "IFB Classes may not be specified in tcrules" if @{$tcdevices{$device}{redirected}};
|
||||
}
|
||||
@ -604,6 +604,7 @@ sub validate_tc_device( ) {
|
||||
fatal_error "Invalid NUMBER:INTERFACE ($device:$number:$rest)" if defined $rest;
|
||||
|
||||
if ( defined $number ) {
|
||||
$number = normalize_hex( $number );
|
||||
$devnumber = hex_value( $number );
|
||||
fatal_error "Invalid interface NUMBER ($number)" unless defined $devnumber && $devnumber;
|
||||
fatal_error "Duplicate interface number ($number)" if defined $devnums[ $devnumber ];
|
||||
|
Loading…
Reference in New Issue
Block a user