forked from extern/shorewall_code
Correct reference counting in one more place in expand_rule()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
ecd2e2276e
commit
a18c502796
@ -1798,10 +1798,10 @@ sub add_jump( $$$;$$$ ) {
|
|||||||
# The global $splitcount is incremented each time that a rule is inserted in the split path.
|
# The global $splitcount is incremented each time that a rule is inserted in the split path.
|
||||||
# Rules in excess of the minimum (1) are accounted for here.
|
# Rules in excess of the minimum (1) are accounted for here.
|
||||||
#
|
#
|
||||||
sub add_expanded_jump( $$$ ) {
|
sub add_expanded_jump( $$$$ ) {
|
||||||
my ( $chainref, $toref, $rule ) = @_;
|
my ( $chainref, $toref, $goto, $rule ) = @_;
|
||||||
our $splitcount = 0;
|
our $splitcount = 0;
|
||||||
add_jump( $chainref, $toref, 0, $rule, 1 );
|
add_jump( $chainref, $toref, $goto, $rule, 1 );
|
||||||
add_reference( $chainref, $toref ) while --$splitcount > 0;
|
add_reference( $chainref, $toref ) while --$splitcount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4547,13 +4547,14 @@ sub expand_rule( $$$$$$$$$$;$ )
|
|||||||
my $jump;
|
my $jump;
|
||||||
my $mac;
|
my $mac;
|
||||||
my $targetref;
|
my $targetref;
|
||||||
|
my $basictarget;
|
||||||
|
|
||||||
if ( $target ) {
|
if ( $target ) {
|
||||||
my ( $basictarget, $rest ) = split ' ', $target, 2;
|
( $basictarget, my $rest ) = split ' ', $target, 2;
|
||||||
|
|
||||||
$jump = '-j ' . $target unless $targetref = $chain_table{$table}{$basictarget};
|
$jump = '-j ' . $target unless $targetref = $chain_table{$table}{$basictarget};
|
||||||
} else {
|
} else {
|
||||||
$jump = '';
|
$jump = $basictarget = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
our @ends = ();
|
our @ends = ();
|
||||||
@ -4940,7 +4941,7 @@ sub expand_rule( $$$$$$$$$$;$ )
|
|||||||
|
|
||||||
for my $dnet ( mysplit $dnets ) {
|
for my $dnet ( mysplit $dnets ) {
|
||||||
$source_match = match_source_net( $inet, $restriction, $mac ) unless $globals{KLUDGEFREE};
|
$source_match = match_source_net( $inet, $restriction, $mac ) unless $globals{KLUDGEFREE};
|
||||||
add_expanded_jump( $chainref, $echainref, join( '', $rule, $source_match, match_dest_net( $dnet ), $onet ) );
|
add_expanded_jump( $chainref, $echainref, 0, join( '', $rule, $source_match, match_dest_net( $dnet ), $onet ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
conditional_rule_end( $chainref ) if $cond;
|
conditional_rule_end( $chainref ) if $cond;
|
||||||
@ -4985,7 +4986,7 @@ sub expand_rule( $$$$$$$$$$;$ )
|
|||||||
# Generate Final Rule
|
# Generate Final Rule
|
||||||
#
|
#
|
||||||
if ( $targetref ) {
|
if ( $targetref ) {
|
||||||
add_expanded_jump( $fromref = $echainref, $targetref, $exceptionrule );
|
add_expanded_jump( $fromref = $echainref, $targetref, 0, $exceptionrule );
|
||||||
} else {
|
} else {
|
||||||
add_rule( $fromref = $echainref, $exceptionrule . $jump , 1 ) unless $disposition eq 'LOG';
|
add_rule( $fromref = $echainref, $exceptionrule . $jump , 1 ) unless $disposition eq 'LOG';
|
||||||
}
|
}
|
||||||
@ -5022,7 +5023,7 @@ sub expand_rule( $$$$$$$$$$;$ )
|
|||||||
# No logging -- add the target rule with matches to the rule chain
|
# No logging -- add the target rule with matches to the rule chain
|
||||||
#
|
#
|
||||||
if ( $targetref ) {
|
if ( $targetref ) {
|
||||||
add_expanded_jump( $fromref = $chainref, $targetref , $matches );
|
add_expanded_jump( $fromref = $chainref, $targetref , 0, $matches );
|
||||||
} else {
|
} else {
|
||||||
add_rule( $fromref = $chainref, $matches . $jump , 1 );
|
add_rule( $fromref = $chainref, $matches . $jump , 1 );
|
||||||
}
|
}
|
||||||
@ -5040,19 +5041,19 @@ sub expand_rule( $$$$$$$$$$;$ )
|
|||||||
'add' ,
|
'add' ,
|
||||||
$matches
|
$matches
|
||||||
);
|
);
|
||||||
} elsif ( $logname || $target =~ /^RETURN\b/ ) {
|
} elsif ( $logname || $basictarget eq 'RETURN' ) {
|
||||||
log_rule_limit(
|
log_rule_limit(
|
||||||
$loglevel ,
|
$loglevel ,
|
||||||
$chainref ,
|
$chainref ,
|
||||||
$logname || $chain,
|
$logname || $chain,
|
||||||
$disposition eq 'reject' ? 'REJECT' : $disposition ,
|
$disposition,
|
||||||
'',
|
'',
|
||||||
$logtag,
|
$logtag,
|
||||||
'add',
|
'add',
|
||||||
$matches );
|
$matches );
|
||||||
|
|
||||||
if ( $targetref ) {
|
if ( $targetref ) {
|
||||||
add_expanded_jump( $fromref = $chainref, $targetref, $matches );
|
add_expanded_jump( $fromref = $chainref, $targetref, 0, $matches );
|
||||||
} else {
|
} else {
|
||||||
add_rule( $fromref = $chainref, $matches . $jump, 1 );
|
add_rule( $fromref = $chainref, $matches . $jump, 1 );
|
||||||
}
|
}
|
||||||
@ -5061,11 +5062,10 @@ sub expand_rule( $$$$$$$$$$;$ )
|
|||||||
# Find/Create a chain that both logs and applies the target action
|
# Find/Create a chain that both logs and applies the target action
|
||||||
# and jump to the log chain if all of the rule's conditions are met
|
# and jump to the log chain if all of the rule's conditions are met
|
||||||
#
|
#
|
||||||
add_jump( $chainref,
|
add_expanded_jump( $chainref,
|
||||||
logchain( $chainref, $loglevel, $logtag, $exceptionrule , $disposition, $target ),
|
logchain( $chainref, $loglevel, $logtag, $exceptionrule , $disposition, $target ),
|
||||||
$builtin_target{$disposition},
|
1,
|
||||||
$matches,
|
$matches );
|
||||||
1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conditional_rule_end( $chainref ) if $cond;
|
conditional_rule_end( $chainref ) if $cond;
|
||||||
|
Loading…
Reference in New Issue
Block a user