iptables multiport only supports up to 15 elements for each protocol (TCP or UDP). That can be single ports or portranges (they count doubble).
This commit extends the check to calculate the amount of used TCP and/or UDP ports of all existing entries in a group, by increasing the amount for the service which should be added.
If the amount of ports for TCP or UDP ports become greater than the limit of 15 the error message will be displayed.
Fixes #11323.
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- html/cgi-bin/fwhosts.cgi | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi index 35611ac08..f6c7227ce 100644 --- a/html/cgi-bin/fwhosts.cgi +++ b/html/cgi-bin/fwhosts.cgi @@ -818,10 +818,28 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp') } } } - if ($tcpcounter > 14){ + + # Loop through the hash of configured services. + foreach my $key (keys %customservice) { + # Assign nice human-readable values. + my $service_name = $customservice{$key}[0]; + my $service_port = $customservice{$key}[1]; + my $service_proto = $customservice{$key}[2]; + + # Skip services unless the processed one has found. + next unless $service_name eq $fwhostsettings{'CUST_SRV'}; + + # Increase the counters. + $tcpcounter++ if $service_proto eq 'TCP'; + $tcpcounter++ if $service_proto eq 'TCP' && $service_port =~ m/:/i; + $udpcounter++ if $service_proto eq 'UDP'; + $udpcounter++ if $service_proto eq 'UDP' && $service_port =~ m/:/i; + } + + if ($tcpcounter > 15) { $errormessage=$Lang::tr{'fwhost err maxservicetcp'}; } - if ($udpcounter > 14){ + if ($udpcounter > 15) { $errormessage=$Lang::tr{'fwhost err maxserviceudp'}; } $tcpcounter=0;