5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-22 21:33:47 +03:00

fix #5141: network parser: fix accidental RE result re-use

$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>
This commit is contained in:
Fabian Grünbichler 2023-12-21 16:30:24 +01:00 committed by Wolfgang Bumiller
parent fcc97ec96d
commit 80ed66dc17

View 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'};