From nobody Sun May 3 08:43:32 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 1744637624346119.09265888214475; Mon, 14 Apr 2025 06:33:44 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7580E149B; Mon, 14 Apr 2025 09:33:43 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 55AB51903; Mon, 14 Apr 2025 09:33:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 40C3214FA; Mon, 14 Apr 2025 09:33:14 -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 A486E1470 for ; Mon, 14 Apr 2025 09:33:13 -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 3F04523381; Mon, 14 Apr 2025 16:33:12 +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: pkrempa@redhat.com, devel@lists.libvirt.org Subject: [PATCH v2 1/1] virsh: prevent potential NULL dereference Date: Mon, 14 Apr 2025 16:32:10 +0300 Message-ID: <20250414133248.32716-2-kuznetsovam@altlinux.org> X-Mailer: git-send-email 2.42.4 In-Reply-To: <20250414133248.32716-1-kuznetsovam@altlinux.org> References: <20250414133248.32716-1-kuznetsovam@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GHHCINOAMDVUSPK4BO3TPSYTLZJZTWL7 X-Message-ID-Hash: GHHCINOAMDVUSPK4BO3TPSYTLZJZTWL7 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: 1744637627362019100 Content-Type: text/plain; charset="utf-8" virXPathString() can return NULL so we need to use STRNEQ_NULLABLE here Found by Linux Verification Center (linuxtesting.org) with Svace. Reported-by: Dmitry Fedin Signed-off-by: Alexander Kuznetsov Reviewed-by: Michal Privoznik --- 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..b6a4d85ee8 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 (STRNEQ_NULLABLE(type, "pty")) continue; =20 tmp[offset++] =3D virXPathString("string(./alias/@name)", ctxt); --=20 2.42.4