[PATCH 2/9] tools: Fix comparison in virLoginShellGetShellArgv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tools/virt-login-shell.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c
index 632d493..a2b32ac 100644
--- a/tools/virt-login-shell.c
+++ b/tools/virt-login-shell.c
@@ -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) {
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]