]> xenbits.xensource.com Git - libvirt.git/commitdiff
tools: Fix comparison in virLoginShellGetShellArgv
authorJohn Ferlan <jferlan@redhat.com>
Mon, 18 Jul 2016 18:07:42 +0000 (14:07 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 19 Jul 2016 11:51:10 +0000 (07:51 -0400)
Commit id '740e4d70' altered the logic to fetch the sysconf values and
added a new virConfGetValueStringList which returns -1 on failure, 0 if
missing, and 1 if the value was present.

However, the caller only checked !shargv which caught Coverity's attention
since the following VIR_ALLOC_N(*shargv, 2) would be a NULL ptr deref

Signed-off-by: John Ferlan <jferlan@redhat.com>
tools/virt-login-shell.c

index 632d49325b197ac6ee980bd58ffb7b4b40fd2910..a2b32ac0c4cb2cf381bdef708bd521afc7a8625a 100644 (file)
@@ -99,10 +99,12 @@ static int virLoginShellGetShellArgv(virConfPtr conf,
                                      char ***shargv,
                                      size_t *shargvlen)
 {
-    if (virConfGetValueStringList(conf, "shell", true, shargv) < 0)
+    int rv;
+
+    if ((rv = virConfGetValueStringList(conf, "shell", true, shargv)) < 0)
         return -1;
 
-    if (!shargv) {
+    if (rv == 0) {
         if (VIR_ALLOC_N(*shargv, 2) < 0)
             return -1;
         if (VIR_STRDUP((*shargv)[0], "/bin/sh") < 0) {