diff options
author | Lee Duncan <lduncan@suse.com> | 2020-06-03 08:42:17 -0700 |
---|---|---|
committer | Lee Duncan <lduncan@suse.com> | 2020-06-03 08:42:17 -0700 |
commit | 3f24547f246ee44000d67c7a9b97ff5704327a60 (patch) | |
tree | 51cdb6e32f5c60d75ffa35850a345152995cc576 /iscsiuio | |
parent | 10009f1c5fc01238be976867bc02be046325850b (diff) | |
download | open-iscsi-3f24547f246ee44000d67c7a9b97ff5704327a60.tar.gz |
Fix compiler complaint about string copy in iscsiuio
This makes the compiler happy when searching for uio%d sysfs
directories.
Diffstat (limited to 'iscsiuio')
-rw-r--r-- | iscsiuio/src/unix/nic_utils.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/iscsiuio/src/unix/nic_utils.c b/iscsiuio/src/unix/nic_utils.c index ec3b915..ec4535d 100644 --- a/iscsiuio/src/unix/nic_utils.c +++ b/iscsiuio/src/unix/nic_utils.c @@ -603,7 +603,10 @@ static int from_uio_find_associated_host(nic_t *nic, int uio_minor, search_filters[path_iterator], alphasort); switch (count) { - case 1: + case 1: { + char *parsed_src; + size_t parsed_size; + parsed_name = (*extract_name[path_iterator]) (files); if (!parsed_name) { LOG_WARN(PFX "Couldn't find delimiter in: %s", @@ -612,15 +615,22 @@ static int from_uio_find_associated_host(nic_t *nic, int uio_minor, break; } - strncpy(name, - parsed_name + - extract_name_offset[path_iterator], name_size); + parsed_src = parsed_name + extract_name_offset[path_iterator]; + parsed_size = strlen(parsed_src); + if (parsed_size >= name_size) { + LOG_WARN(PFX "uio device name too long: %s (max %d)", + parsed_src, (int)name_size - 1); + rc = -EINVAL; + } else { + strncpy(name, parsed_src, name_size); + rc = 0; + } free(files[0]); free(files); - rc = 0; break; + } case 0: rc = -EINVAL; |