From 5cdb74168f86f0cf439b23dca14e0456b8d11c46 Mon Sep 17 00:00:00 2001
From: Tom Eastep <teastep@shorewall.net>
Date: Fri, 25 Nov 2011 16:22:23 -0800
Subject: [PATCH] Correct port list capture with --multiport.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
---
 Shorewall/Perl/Shorewall/Chains.pm | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/Shorewall/Perl/Shorewall/Chains.pm b/Shorewall/Perl/Shorewall/Chains.pm
index 80fef7ec8..3a1ba6894 100644
--- a/Shorewall/Perl/Shorewall/Chains.pm
+++ b/Shorewall/Perl/Shorewall/Chains.pm
@@ -2853,7 +2853,13 @@ sub get_dports( $ ) {
 	if ( my $multiref = $ruleref->{multiport} ) {
 	    if ( reftype $multiref ) {
 		for ( @$multiref ) {
-		    $ports .= ",$1" if /^--dports (.*)/;
+		    if ( /^--dports (.*)/ ) {
+			if ( $ports ) {
+			    $ports .= ",$1";
+			} else {
+			    $ports = $1;
+			}
+		    }
 		}
 	    } else {
 		$ports = $1 if $multiref =~ /^--dports (.*)/;
@@ -2873,7 +2879,13 @@ sub get_multi_sports( $ ) {
     if ( my $multiref = $_[0]->{multiport} ) {
 	if ( reftype $multiref ) {
 	    for ( @$multiref ) {
-		$ports .= ",$1" if /^--sports (.*)/;
+		if ( /^--sports (.*)/ ) {
+		    if ( $ports ) {
+			$ports .= ",$1";
+		    } else {
+			$ports = $1;
+		    }
+		}
 	    }
 	} else {
 	    $ports = $1 if $multiref =~ /^--sports (.*)/;