From nobody Mon Sep 8 17:06:06 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; dkim=fail; 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 1752673857741615.8250810998711; Wed, 16 Jul 2025 06:50:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B4EBC1403; Wed, 16 Jul 2025 09:50:56 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4FC221345; Wed, 16 Jul 2025 09:50:41 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D7DF61287; Wed, 16 Jul 2025 09:50:37 -0400 (EDT) Received: from mail-gw02.astralinux.ru (mail-gw02.astralinux.ru [93.188.205.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 874961261 for ; Wed, 16 Jul 2025 09:50:36 -0400 (EDT) Received: from gca-msk-a-srv-ksmg01.astralinux.ru (localhost [127.0.0.1]) by mail-gw02.astralinux.ru (Postfix) with ESMTP id 2E5641F9EB; Wed, 16 Jul 2025 16:43:39 +0300 (MSK) Received: from new-mail.astralinux.ru (unknown [10.177.185.211]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-gw02.astralinux.ru (Postfix) with ESMTPS; Wed, 16 Jul 2025 16:43:38 +0300 (MSK) Received: from localhost.localdomain (unknown [10.190.6.106]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4bhy223MWZz1J9kq; Wed, 16 Jul 2025 16:43:38 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 409 seconds by postgrey-1.37 at lists.libvirt.org; Wed, 16 Jul 2025 09:50:36 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=astralinux.ru; s=mail; t=1752673419; bh=N/KQ73wDmPiGqAqMSPdBE5RcEeokjT6QQKBMp3Vpwfs=; h=From:To:Cc:Subject:Date:From; b=sYpBlOxxS1/dDfl0GVJ1z7QtS3+TJ2JlEo4ugDL+cSihier9OQTP2agC07rqPiR27 eW/ysVrT2H0GanD2ECnodFlCuQ2Xj2nXh51p/OXXhViBJSKYbYqxhSsP5vgxkwF/RH ztOT+wTyJxnM86XeRR+4XTs3zVdUQknCRTVY6EoIX/ETZ5Mk2ZkLhNg2k7ruQVZWHk DY7cTqnBzChpK1B1uxEwUD1WQDObCfFRR5a4gJyv7FWSmIVEOYCvBfS35ccpiHFPNP hnyNwM4ubSGozfHuRvDkeLsfdkuXpxeFyQE+lg/D/LyqBqjEd3S5RujundgJe2y1rT XRVhiMuqtgz3g== From: Anastasia Belova To: devel@lists.libvirt.org Subject: [PATCH] virshFindDisk: fix NULL-dereference of xmlCopyNode() result Date: Wed, 16 Jul 2025 16:42:14 +0300 Message-ID: <20250716134323.9868-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Envelope-From: abelova@astralinux.ru X-KSMG-AntiSpam-Info: LuaCore: 63 0.3.63 9cc2b4b18bf16653fda093d2c494e542ac094a39, {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to}, astralinux.ru:7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;new-mail.astralinux.ru:7.1.1, FromAlignment: s X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiSpam-Lua-Profiles: 194888 [Jul 16 2025] X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Version: 6.1.1.11 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/07/16 12:49:00 #27639138 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: NotDetected X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JX2OIQRFFLB7TYPAJ73UWCUALC2QKJOI X-Message-ID-Hash: JX2OIQRFFLB7TYPAJ73UWCUALC2QKJOI X-MailFrom: abelova@astralinux.ru X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: sdl.libvirt@linuxtesting.org, Anastasia Belova X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1752673860596116600 Content-Type: text/plain; charset="utf-8" xmlCopyNode() may return NULL. Add a check and log an error in this case. Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: 22766a1a53 ("virshFindDisk: Sanitize use of 'tmp' variable") Signed-off-by: Anastasia Belova Reviewed-by: Peter Krempa --- tools/virsh-domain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7253596f4a..8752294784 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12875,6 +12875,10 @@ virshFindDisk(const char *doc, STREQ_NULLABLE(sourceDir, path) || STREQ_NULLABLE(sourceName, path)) { xmlNodePtr ret =3D xmlCopyNode(nodes[i], 1); + if (!ret) { + vshError(NULL, "%s", _("Failed to copy node")); + return NULL; + } /* drop backing store since they are not needed here */ virshDiskDropBackingStore(ret); return ret; --=20 2.43.0