提交 43d1616f 编写于 作者: S Stefan Berger 提交者: Stefan Berger

node_device: fix possible non-terminated string

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.
上级 b4586051
...@@ -70,14 +70,13 @@ int read_wwn_linux(int host, const char *file, char **wwn) ...@@ -70,14 +70,13 @@ int read_wwn_linux(int host, const char *file, char **wwn)
{ {
char *p = NULL; char *p = NULL;
int fd = -1, retval = 0; int fd = -1, retval = 0;
char buf[64]; char buf[65] = "";
if (open_wwn_file(LINUX_SYSFS_FC_HOST_PREFIX, host, file, &fd) < 0) { if (open_wwn_file(LINUX_SYSFS_FC_HOST_PREFIX, host, file, &fd) < 0) {
goto out; goto out;
} }
memset(buf, 0, sizeof(buf)); if (saferead(fd, buf, sizeof(buf) - 1) < 0) {
if (saferead(fd, buf, sizeof(buf)) < 0) {
retval = -1; retval = -1;
VIR_DEBUG("Failed to read WWN for host%d '%s'", VIR_DEBUG("Failed to read WWN for host%d '%s'",
host, file); host, file);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册