From nobody Tue May 5 10:09:50 2026 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 1744631814561164.6600292753319; Mon, 14 Apr 2025 04:56:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E927715E6; Mon, 14 Apr 2025 07:56:53 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1F66B1519; Mon, 14 Apr 2025 07:56:39 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B55B114E4; Mon, 14 Apr 2025 07:56:35 -0400 (EDT) Received: from air.basealt.ru (air.basealt.ru [193.43.8.18]) (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 AC1D71418 for ; Mon, 14 Apr 2025 07:56:34 -0400 (EDT) Received: from kuznetsovam-nb.office.basealt.ru (unknown [193.43.10.250]) (Authenticated sender: kuznetsovam) by air.basealt.ru (Postfix) with ESMTPSA id 57BA6233A8; Mon, 14 Apr 2025 14:56:31 +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=-1.0 required=5.0 tests=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 From: Alexander Kuznetsov To: devel@lists.libvirt.org Subject: [PATCH] virsh: prevent potential NULL dereference Date: Mon, 14 Apr 2025 14:56:03 +0300 Message-ID: <20250414115617.21146-1-kuznetsovam@altlinux.org> X-Mailer: git-send-email 2.42.4 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: L5LMYMRP43QSNDH2VHKU7U3B5H32LVDJ X-Message-ID-Hash: L5LMYMRP43QSNDH2VHKU7U3B5H32LVDJ X-MailFrom: kuznetsovam@altlinux.org 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: nickel@altlinux.org, egori@altlinux.org 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-ZM-MESSAGEID: 1744631818121019000 Content-Type: text/plain; charset="utf-8" virXPathString() can return NULL so we need to check it before calling strc= mp() Found by Linux Verification Center (linuxtesting.org) with Svace. Reported-by: Dmitry Fedin Signed-off-by: Alexander Kuznetsov --- tools/virsh-completer-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 0a3a113dca..abacfd04c1 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -891,7 +891,7 @@ virshDomainConsoleCompleter(vshControl *ctl, ctxt->node =3D parallels[i - nserials]; =20 type =3D virXPathString("string(./@type)", ctxt); - if (STRNEQ(type, "pty")) + if (!type || STRNEQ(type, "pty")) continue; =20 tmp[offset++] =3D virXPathString("string(./alias/@name)", ctxt); --=20 2.42.4