]> git.proxmox.com Git - pve-firewall.git/commitdiff
check multiport limit in port ranges
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 8 Mar 2018 11:06:21 +0000 (12:06 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 8 Mar 2018 11:18:20 +0000 (12:18 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/Firewall.pm

index 2feac5497ac0ce4160950f6cd66c8d448be85ee5..bc3d9fe083b4d2c28ba7871dabddb4db1a810ef8 100644 (file)
@@ -1035,12 +1035,13 @@ sub parse_port_name_number_or_range {
     my @elements = split(/,/, $str);
     die "extraneous commas in list\n" if $str ne join(',', @elements);
     foreach my $item (@elements) {
-       $count++;
        if ($item =~ m/^(\d+):(\d+)$/) {
+           $count += 2;
            my ($port1, $port2) = ($1, $2);
            die "invalid port '$port1'\n" if $port1 > 65535;
            die "invalid port '$port2'\n" if $port2 > 65535;
        } elsif ($item =~ m/^(\d+)$/) {
+           $count += 1;
            my $port = $1;
            die "invalid port '$port'\n" if $port > 65535;
        } else {
@@ -1054,7 +1055,13 @@ sub parse_port_name_number_or_range {
        }
     }
 
-    die "ICPM ports not allowed in port range\n" if $icmp_port && $count > 1;
+    die "ICPM ports not allowed in port range\n" if $icmp_port && $count > 0;
+
+    # I really don't like to use the word number here, but it's the only thing
+    # that makes sense in a literal way. The range 1:100 counts as 2, not as
+    # one and not as 100...
+    die "too many entries in port list (> 15 numbers)\n"
+       if $count > 15;
 
     return $count;
 }