mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
coverity: ensure 0 end string
Use dm_strncpy() to enusure string ends with '\0'. In case uuid does not fit, report error.
This commit is contained in:
parent
037c234eaa
commit
fa5ba7e42d
@ -1631,7 +1631,7 @@ int create_cluster_cpg(char *uuid, uint64_t luid)
|
||||
|
||||
size = ((strlen(uuid) + 1) > CPG_MAX_NAME_LENGTH) ?
|
||||
CPG_MAX_NAME_LENGTH : (strlen(uuid) + 1);
|
||||
strncpy(new->name.value, uuid, size);
|
||||
(void) dm_strncpy(new->name.value, uuid, size);
|
||||
new->name.length = (uint32_t)size;
|
||||
new->luid = luid;
|
||||
|
||||
|
@ -451,15 +451,19 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
||||
lc->skip_bit_warning = region_count;
|
||||
lc->disk_fd = -1;
|
||||
lc->log_dev_failed = 0;
|
||||
strncpy(lc->uuid, uuid, DM_UUID_LEN);
|
||||
if (!dm_strncpy(lc->uuid, uuid, DM_UUID_LEN)) {
|
||||
LOG_ERROR("Cannot use too long UUID %s.", uuid);
|
||||
r = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
lc->luid = luid;
|
||||
|
||||
if (get_log(lc->uuid, lc->luid) ||
|
||||
get_pending_log(lc->uuid, lc->luid)) {
|
||||
LOG_ERROR("[%s/%" PRIu64 "u] Log already exists, unable to create.",
|
||||
SHORT_UUID(lc->uuid), lc->luid);
|
||||
dm_free(lc);
|
||||
return -EINVAL;
|
||||
r = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dm_list_init(&lc->mark_list);
|
||||
|
Loading…
Reference in New Issue
Block a user