]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: fix entering interactive session
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sat, 23 May 2026 07:24:48 +0000 (09:24 +0200)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Mon, 25 May 2026 08:58:15 +0000 (10:58 +0200)
When entering an interactive session, that is, without a command
specified:

  virsh --connect $URI

virsh currently segfaults because it tries to access
ctl->cmd->def->handler and the ctl->cmd is NULL.

Fix by checking if ctl->cmd is not NULL before doing further checks.

Fixes: b489eb8d6b52d4183754a5d1da55006148a331e4
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
tools/virsh.c

index 72d233f98d0b3b006f3aa5c30fd6e605b251342a..401d4f9787bd0c8630f2e1ece513fe681e387e8f 100644 (file)
@@ -126,7 +126,7 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly)
         virErrorPtr err;
         virConnectAuthPtr auth = virConnectAuthPtrDefault;
 
-        if (ctl->cmd->def->handler == cmdComplete) {
+        if (ctl->cmd && ctl->cmd->def->handler == cmdComplete) {
             /* When running from a bash completer we need to avoid any kind of
              * keyboard input (e.g. ssh asking for a password). To achieve
              * this, provide no authentication callbacks. */