From: Jim Fehlig Date: Tue, 4 Aug 2026 17:27:59 +0000 (-0600) Subject: Commit 9899c91515 introduced the potential for a NULL pointer dereference X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6560a7223927e1e5fa249572750bc376bba67fa;p=thirdparty%2Flibvirt.git Commit 9899c91515 introduced the potential for a NULL pointer dereference crash when the 'ctl' parameter to vshPrintStderr() is NULL. Below is an example backtrace of the crash when attempting to detach a non-existent disk with 'virsh detach-disk test vdz' #0 vshPrintStderr (ctl=0x0, level=4, format=, ap=) at ../tools/vsh.c:2148 #1 0x00005555555e6b2c in vshError (ctl=ctl@entry=0x0, format=) at ../tools/vsh.c:2170 #2 0x00005555555afec7 in virshFindDisk (doc=doc@entry=0x555555696ee0 "\n test\n 9b27a21e-dfa2-4c1e-9d11-2de275aefb03\n \n , argv=0x7fffffffdeb8) at ../tools/virsh.c:908 Ensure 'ctl' is valid before dereferencing it. Fixes: 9899c91515d79595d19800ccc895df18eb7bb3f7 Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrangé --- diff --git a/tools/vsh.c b/tools/vsh.c index ccf2f21d64..667cc1a0d2 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2145,7 +2145,7 @@ vshPrintStderr(vshControl *ctl, if (ctl) vshOutputLogFile(ctl, level, str); - if (ctl->stderr_closed) + if (ctl && ctl->stderr_closed) return; /* Most output is to stdout, but if someone ran virsh 2>&1, then