[PATCH V2 2/2] node_device: fix possible non-terminated string

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

 



Error: STRING_NULL:
/libvirt/src/node_device/node_device_linux_sysfs.c:80:
string_null_argument: Function "saferead" does not terminate string "*buf".
/libvirt/src/util/util.c:101:
string_null_argument: Function "read" fills array "*buf" with a non-terminated string.
/libvirt/src/node_device/node_device_linux_sysfs.c:87:
string_null: Passing unterminated string "buf" to a function expecting a null-terminated string.

---
 src/node_device/node_device_linux_sysfs.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Index: libvirt-acl/src/node_device/node_device_linux_sysfs.c
===================================================================
--- libvirt-acl.orig/src/node_device/node_device_linux_sysfs.c
+++ libvirt-acl/src/node_device/node_device_linux_sysfs.c
@@ -70,14 +70,13 @@ int read_wwn_linux(int host, const char 
 {
     char *p = NULL;
     int fd = -1, retval = 0;
-    char buf[64];
+    char buf[65] = "";
 
     if (open_wwn_file(LINUX_SYSFS_FC_HOST_PREFIX, host, file, &fd) < 0) {
         goto out;
     }
 
-    memset(buf, 0, sizeof(buf));
-    if (saferead(fd, buf, sizeof(buf)) < 0) {
+    if (saferead(fd, buf, sizeof(buf) - 1) < 0) {
         retval = -1;
         VIR_DEBUG("Failed to read WWN for host%d '%s'",
                   host, file);

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