[PATCH v2 4/6] esx: Resolve Coverity FORWARD_NULL

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

 



Coverity complains that strtok_r cannot be called if the first and third
parameters are NULL. On entry, the 'path' parameter is not checked for
being NULL before the VIR_STRDUP which will set the target to NULL if
the source (eg path) is NULL.  Thus add a check for NULL path.

NB: Checks were made in the caller to only call this function if that
parameter was non-NULL; however, that didn't satisfy the checker. The
check had to be in this function.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/esx/esx_vi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index af822b1..1b46c10 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -1169,6 +1169,11 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
     esxVI_ManagedObjectReference *root = NULL;
     esxVI_Folder *folder = NULL;
 
+    if (!path) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s", _("Path is empty"));
+        goto cleanup;
+    }
+
     if (VIR_STRDUP(tmp, path) < 0)
         goto cleanup;
 
-- 
2.1.0

--
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]