]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: prevent potential NULL dereference
authorAlexander Kuznetsov <kuznetsovam@altlinux.org>
Mon, 14 Apr 2025 13:32:10 +0000 (16:32 +0300)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Apr 2025 10:54:54 +0000 (12:54 +0200)
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 <d.fedin@fobos-nt.ru>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer-domain.c

index 0a3a113dcaf72eba1ae49f8eb5c8ad3eca50471c..b6a4d85ee8df2963346e09547cee37949c5be03e 100644 (file)
@@ -891,7 +891,7 @@ virshDomainConsoleCompleter(vshControl *ctl,
             ctxt->node = parallels[i - nserials];
 
         type = virXPathString("string(./@type)", ctxt);
-        if (STRNEQ(type, "pty"))
+        if (STRNEQ_NULLABLE(type, "pty"))
             continue;
 
         tmp[offset++] = virXPathString("string(./alias/@name)", ctxt);