]> git.proxmox.com Git - pve-common.git/commitdiff
fix #5141: network parser: fix accidental RE result re-use
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 21 Dec 2023 15:30:24 +0000 (16:30 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 3 Jan 2024 11:16:14 +0000 (12:16 +0100)
$1 and friends are not cleared if a RE fails to match, in which case they will
contain the captured values from a previous successful match in the same scope.

deduplicate the two branches to avoid accidental re-introduction.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/PVE/INotify.pm

index 601e651d3e540f74c136fdd11e9ec70a96987f5b..643229567df5e7707868fb03b52305f02e45a42e 100644 (file)
@@ -1073,16 +1073,27 @@ sub __read_etc_network_interfaces {
                $ifaces->{$1}->{exists} = 0;
                $d->{exists} = 0;
            }
-       } elsif ($iface =~ m/^(\S+)\.(\d+)$/ || $d->{'vlan-raw-device'}) {
+       } elsif ($iface =~ m/^(\S+)\.(\d+)$/) {
            $d->{type} = 'vlan';
 
            my ($dev, $id) = ($1, $2);
            $d->{'vlan-raw-device'} = $dev if defined($dev) && !$d->{'vlan-raw-device'};
+           $d->{'vlan-id'} = $id if $id; # VLAN id 0 is not valid, so truthy check it is
 
-           if (!$id && $iface =~ m/^vlan(\d+)$/) { # VLAN id 0 is not valid, so truthy check it is
-               $id = $1;
+           my $raw_iface = $d->{'vlan-raw-device'};
+
+           if (defined ($ifaces->{$raw_iface})) {
+               $d->{exists} = $ifaces->{$raw_iface}->{exists};
+           } else {
+               $ifaces->{$raw_iface}->{exists} = 0;
+               $d->{exists} = 0;
+           }
+       } elsif ($d->{'vlan-raw-device'}) {
+           $d->{type} = 'vlan';
+
+           if ($iface =~ m/^vlan(\d+)$/) {
+               $d->{'vlan-id'} = $1 if $1; # VLAN id 0 is not valid, so truthy check it is
            }
-           $d->{'vlan-id'} = $id if $id;
 
            my $raw_iface = $d->{'vlan-raw-device'};