From: Julio Faracco Date: Wed, 28 Feb 2018 01:17:54 +0000 (-0300) Subject: virsh: fixing segfault by pool autocompleter function. X-Git-Tag: v4.1.0-rc2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fe09a53170a96962d6f795ff9b6034ff9d0fb7f;p=thirdparty%2Flibvirt.git virsh: fixing segfault by pool autocompleter function. The commands which requires a pool to perform any action for a volume is throwing a segfault when you pass the volume name before a pool name or without the argument '--pool'. An example that works: virsh # vol-list loops-pool Name Path ------------------------------------------------------------------- loop0 /mnt/loop0 virsh # vol-info --pool loops-pool lo An example that does not work: virsh # vol-list loops-pool Name Path ------------------------------------------------------------------- loop0 /mnt/loop0 virsh # vol-info lo Segmentation Fault The example 'vol-info' can be executed as 'vol-info loop0 --pool loops-pool'. So, this commit fixes this problem when the arguments are inverted and avoids the segfault. Signed-off-by: Julio Faracco Signed-off-by: Michal Privoznik --- diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 56b6cfc73d..9c7e972bad 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -143,6 +143,9 @@ virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname, if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) return NULL; + if (cmd->skipChecks && !n) + return NULL; + vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n", cmd->def->name, optname, n);