]> git.proxmox.com Git - pve-firewall.git/commitdiff
parse_address_list: only allow one ip range
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 3 Apr 2014 07:25:28 +0000 (09:25 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 3 Apr 2014 07:25:28 +0000 (09:25 +0200)
The previous check did not work if the range is the first entry in the list,
for example:

IN  ACCEPT net0 10.0.0.1-10.0.0.10,10.0.0.12

src/PVE/Firewall.pm

index e060244e9d26439f3cffc5df0c270bec8c42ebfe..88fc044315a77aed0664dbbf4455a83e960d764a 100644 (file)
@@ -613,18 +613,18 @@ sub get_etc_protocols {
 sub parse_address_list {
     my ($str) = @_;
 
-    my $nbaor = 0;
-    foreach my $aor (split(/,/, $str)) {
-       if($nbaor > 0 && $aor =~ m/-/){
-           die "you can use a range in a list";
-       }
-       if (!Net::IP->new($aor)) {
+    my $count = 0;
+    my $iprange = 0;
+    foreach my $elem (split(/,/, $str)) {
+       $count++;
+       if (!Net::IP->new($elem)) {
            my $err = Net::IP::Error();
            die "invalid IP address: $err\n";
-       }else{
-           $nbaor++;
        }
+       $iprange = 1 if $elem =~ m/-/;
     }
+    
+    die "you can use a range in a list\n" if $iprange && $count > 1;
 }
 
 sub parse_port_name_number_or_range {