Leave space for terminating buffers with null

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2022-06-24 08:05:11 +02:00
parent bead2af4f4
commit d9e643a41a

View File

@ -1712,7 +1712,7 @@ int cache_mngt_set_partitions(const char *cache_name, size_t name_len,
name_len, &cache); name_len, &cache);
if (result) if (result)
goto out_get; goto out_get;
if (ocf_cache_is_standby(cache)) { if (ocf_cache_is_standby(cache)) {
result = -OCF_ERR_CACHE_STANDBY; result = -OCF_ERR_CACHE_STANDBY;
goto out_standby; goto out_standby;
@ -2390,7 +2390,7 @@ int cache_mngt_activate(struct ocf_mngt_cache_standby_activate_config *cfg,
/* TODO: doesn't this need to be copied to avoid use-after-free /* TODO: doesn't this need to be copied to avoid use-after-free
* in case where calle is interrupted and returns??? * in case where calle is interrupted and returns???
*/ */
strncpy(context->cache_path, cmd->cache_path, MAX_STR_LEN); strncpy(context->cache_path, cmd->cache_path, MAX_STR_LEN-1);
context->device_cfg = &cfg->device; context->device_cfg = &cfg->device;
context->cache = cache; context->cache = cache;
@ -2530,7 +2530,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
return result; return result;
} }
strncpy(context->cache_path, cmd->cache_path_name, MAX_STR_LEN); strncpy(context->cache_path, cmd->cache_path_name, MAX_STR_LEN-1);
context->device_cfg = &attach_cfg->device; context->device_cfg = &attach_cfg->device;
_cache_mngt_async_context_init(&context->async); _cache_mngt_async_context_init(&context->async);