From c0382b8cb9e5d534f9d903387b8d100e0a6cbb9e Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sat, 18 Sep 2010 15:11:17 -0700 Subject: [PATCH] Adjust reference count in move rules. Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Chains.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Shorewall/Perl/Shorewall/Chains.pm b/Shorewall/Perl/Shorewall/Chains.pm index 74026ea6a..43a495ec2 100644 --- a/Shorewall/Perl/Shorewall/Chains.pm +++ b/Shorewall/Perl/Shorewall/Chains.pm @@ -762,7 +762,19 @@ sub copy_rules( $$ ) { my $last = pop @$rules2; # Delete the jump to chain1 if ( $blacklist2 && $blacklist1 ) { - shift @rules1; + # + # Chains2 already has a blacklist jump -- delete the one at the head of chain1's rule list + # + my $rule = shift @rules1; + + $rule =~ / -j ([^\s])/; + + my $chainb = $1; + + assert( $chainb =~ /^black/ ); + + delete $tableref->{$chainb}{references}{$name1} unless --$tableref->{$chainb}{references}{$name1} > 0; + assert( ! --$chain1->{blacklist} ); $blacklist1 = 0; }