[PATCH 2/2] nss: Need to check error condition on virJSONValueArraySize

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

 



If the 'nleases < 0' on return, then the subsequent call to
findLeaseInJSON will not produce the expected results (passed
in as a size_t, but nleases is a ssize_t).  So check if the
returned value < 0 and if so, goto cleanup.

Found by Coverity as a NEGATIVE_RETURNS event

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 tools/nss/libvirt_nss.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 418c11f..b69e62c 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -309,7 +309,8 @@ findLease(const char *name,
     }
     VIR_DIR_CLOSE(dir);
 
-    nleases = virJSONValueArraySize(leases_array);
+    if ((nleases = virJSONValueArraySize(leases_array)) < 0)
+        goto cleanup;
     DEBUG("Read %zd leases", nleases);
 
 #if !defined(LIBVIRT_NSS_GUEST)
-- 
2.7.4

--
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]
  Powered by Linux