]> git.proxmox.com Git - pve-common.git/commitdiff
fix #2374: bridge-ports is assumed to be defined
authorMira Limbeck <m.limbeck@proxmox.com>
Wed, 10 Jun 2020 14:03:38 +0000 (16:03 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 15 Jun 2020 12:26:46 +0000 (14:26 +0200)
bridge-ports is an optional parameter but was assumed to be defined in
the code. This resulted in 'use of uninitialized value' warnings.

By reordering of the $ports definition before the replace, we get rid of
the 'use of uninitialized value' when no bridge-port is specified.

In the second case we set it to an empty string when it is undefined.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
src/PVE/INotify.pm

index c50751560b20de5955fee91a46ab7d4394c0c3c1..f524672e6cfd6827ceea891bffa44bd0f2996344 100644 (file)
@@ -1236,8 +1236,8 @@ sub __interface_to_string {
        # not printing out options
     } elsif ($d->{type} eq 'bridge') {
 
        # not printing out options
     } elsif ($d->{type} eq 'bridge') {
 
-       $d->{bridge_ports} =~ s/[;,\s]+/ /g;
        my $ports = $d->{bridge_ports} || 'none';
        my $ports = $d->{bridge_ports} || 'none';
+       $ports =~ s/[;,\s]+/ /g;
        $raw .= "\tbridge-ports $ports\n";
        $done->{bridge_ports} = 1;
 
        $raw .= "\tbridge-ports $ports\n";
        $done->{bridge_ports} = 1;
 
@@ -1605,7 +1605,7 @@ sub __write_etc_network_interfaces {
     foreach my $iface (keys %$ifaces_copy) {
        my $d = $ifaces_copy->{$iface};
        if ($d->{type} eq 'bridge') {
     foreach my $iface (keys %$ifaces_copy) {
        my $d = $ifaces_copy->{$iface};
        if ($d->{type} eq 'bridge') {
-           foreach my $p (split (/\s+/, $d->{bridge_ports})) {
+           foreach my $p (split (/\s+/, $d->{bridge_ports} // '')) {
                if($p =~ m/(\S+)\.(\d+)$/) {
                    my $vlanparent = $1;
                    if (!defined($ifaces_copy->{$p})) {
                if($p =~ m/(\S+)\.(\d+)$/) {
                    my $vlanparent = $1;
                    if (!defined($ifaces_copy->{$p})) {