]> git.proxmox.com Git - pve-firewall.git/commitdiff
forbid trailing commas in lists
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 22 Mar 2017 11:53:33 +0000 (12:53 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 10 Apr 2017 12:57:36 +0000 (14:57 +0200)
iptables-restore doesn't allow them

src/PVE/Firewall.pm

index c7d90f82fde92a442c3255d4656d5775e6b5be67..0535d780ee1e40e0e56890b89424b02b522e3593 100644 (file)
@@ -976,7 +976,9 @@ sub parse_address_list {
     my $iprange = 0;
     my $ipversion;
 
-    foreach my $elem (split(/,/, $str)) {
+    my @elements = split(/,/, $str);
+    die "extraneous commas in list\n" if $str ne join(',', @elements);
+    foreach my $elem (@elements) {
        $count++;
        my $ip = Net::IP->new($elem);
        if (!$ip) {
@@ -1005,7 +1007,9 @@ sub parse_port_name_number_or_range {
     my $count = 0;
     my $icmp_port = 0;
 
-    foreach my $item (split(/,/, $str)) {
+    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+)$/) {
            my ($port1, $port2) = ($1, $2);