]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: add file exists check in virReadFCHost
authorBoris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Mon, 16 Jan 2017 13:27:33 +0000 (14:27 +0100)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 18 Jan 2017 11:25:55 +0000 (06:25 -0500)
File open errors are prevented by a file exists check before
virFileReadAll is called since all callers of the virReadFCHost
method handle errors themselves based on the NULL return anyway.
Also included is a minor spelling correction in a comment.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
src/util/virutil.c

index aeaa7f98e8cf9e2faef1c848bf419444c74d373f..91178d151570d20c6a7062def8c463b9004a98a2 100644 (file)
@@ -2011,7 +2011,7 @@ virGetSCSIHostNameByParentaddr(unsigned int domain,
  *
  * Read the value of sysfs "fc_host" entry.
  *
- * Returns result as a stringon success, caller must free @result after
+ * Returns result as a string on success, caller must free @result after
  * Otherwise returns NULL.
  */
 char *
@@ -2029,6 +2029,9 @@ virReadFCHost(const char *sysfs_prefix,
                     host, entry) < 0)
         goto cleanup;
 
+    if (!virFileExists(sysfs_path))
+        goto cleanup;
+
     if (virFileReadAll(sysfs_path, 1024, &buf) < 0)
         goto cleanup;