From 45f67709ea91fb4e6e487c56e1958b324be4f817 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 5 Mar 2025 12:06:28 +0100 Subject: [PATCH] api: termproxy/vncproxy: fix 'use of uninitialized value' when checking vga type in our schema for 'vga' the type is optional, so a config like vga: memory=64 is valid. When checking the type we have to check if the type is defined before accessing it. Signed-off-by: Dominik Csapak [FE: add 'termproxy/vncproxy' prefix to commit title] Signed-off-by: Fiona Ebner --- PVE/API2/Qemu.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 5ac61aa5..dc8915a7 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -2573,7 +2573,7 @@ __PACKAGE__->register_method({ my $serial; if ($conf->{vga}) { my $vga = PVE::QemuServer::parse_vga($conf->{vga}); - $serial = $vga->{type} if $vga->{type} =~ m/^serial\d+$/; + $serial = $vga->{type} if defined($vga->{type}) && $vga->{type} =~ m/^serial\d+$/; } my $authpath = "/vms/$vmid"; @@ -2723,7 +2723,7 @@ __PACKAGE__->register_method({ if (!defined($serial)) { if ($conf->{vga}) { my $vga = PVE::QemuServer::parse_vga($conf->{vga}); - $serial = $vga->{type} if $vga->{type} =~ m/^serial\d+$/; + $serial = $vga->{type} if defined($vga->{type}) && $vga->{type} =~ m/^serial\d+$/; } }