From nobody Tue Dec 16 11:46:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1759312346752422.0722023753576; Wed, 1 Oct 2025 02:52:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9E83F44016; Wed, 1 Oct 2025 05:52:25 -0400 (EDT) Received: from [172.19.199.14] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 0B24044052; Wed, 1 Oct 2025 05:50:16 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id A09FA43E88; Mon, 29 Sep 2025 13:05:04 -0400 (EDT) Received: from air.basealt.ru (air.basealt.ru [193.43.8.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id AE20743E82 for ; Mon, 29 Sep 2025 13:05:03 -0400 (EDT) Received: from boringlust.malta.altlinux.ru (obninsk.basealt.ru [217.15.195.17]) (Authenticated sender: rastyoginds) by air.basealt.ru (Postfix) with ESMTPSA id 2C07B2336B for ; Mon, 29 Sep 2025 19:56:31 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 From: gerben@altlinux.org To: devel@lists.libvirt.org Subject: [PATCH] virt-login-shell: check for NULL from virGetLastError() Date: Mon, 29 Sep 2025 19:55:55 +0300 Message-ID: <20250929165615.176008-1-gerben@altlinux.org> X-Mailer: git-send-email 2.42.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MailFrom: gerben@altlinux.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation Message-ID-Hash: H6ZGNDLNEFVVLZL74GF65IA7SI77E7WY X-Message-ID-Hash: H6ZGNDLNEFVVLZL74GF65IA7SI77E7WY X-Mailman-Approved-At: Wed, 01 Oct 2025 09:50:03 +0000 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZM-MESSAGEID: 1759312348500116600 Content-Type: text/plain; charset="utf-8" From: Denis Rastyogin virGetLastError() may return NULL in case of OOM. Without a check this could lead to a NULL pointer dereference when accessing its fields. The result of virGetLastError() is usually checked in other places, so add the missing check here as well. Found by Linux Verification Center (linuxtesting.org) with SVACE. Reported-by: Pavel Nekrasov Signed-off-by: Denis Rastyogin --- tools/virt-login-shell-helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index cb59b5dec0..9282ca481e 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -282,6 +282,10 @@ main(int argc, char **argv) if (!virDomainIsActive(dom) && virDomainCreate(dom) < 0) { virErrorPtr last_error; last_error =3D virGetLastError(); + + if (!last_error) + goto cleanup; + if (last_error->code !=3D VIR_ERR_OPERATION_INVALID) { virReportSystemError(last_error->code, _("Can't create %1$s container: %2$s"), --=20 2.42.2