all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] api: fix 'use of uninitialized value' when checking vga type
Date: Wed,  5 Mar 2025 12:06:28 +0100	[thread overview]
Message-ID: <20250305110628.1355517-1-d.csapak@proxmox.com> (raw)

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 <d.csapak@proxmox.com>
---
 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+$/;
 	    }
 	}
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


             reply	other threads:[~2025-03-05 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05 11:06 Dominik Csapak [this message]
2025-03-05 13:45 ` [pve-devel] applied: " Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250305110628.1355517-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal