1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

cov: ensure string ends with \0

Use dm_strncpy() that ensures \0 termination.
This commit is contained in:
Zdenek Kabelac 2024-03-25 00:53:02 +01:00
parent 835e8f9d7a
commit bca6f58848
2 changed files with 8 additions and 8 deletions

View File

@ -5719,9 +5719,9 @@ static void adopt_locks(void)
act->flags = (LD_AF_ADOPT | LD_AF_PERSISTENT); act->flags = (LD_AF_ADOPT | LD_AF_PERSISTENT);
act->client_id = INTERNAL_CLIENT_ID; act->client_id = INTERNAL_CLIENT_ID;
act->lm_type = ls->lm_type; act->lm_type = ls->lm_type;
strncpy(act->vg_name, ls->vg_name, MAX_NAME); (void)dm_strncpy(act->vg_name, ls->vg_name, MAX_NAME);
strncpy(act->lv_uuid, r->name, MAX_NAME); (void)dm_strncpy(act->lv_uuid, r->name, MAX_NAME);
strncpy(act->lv_args, r->lv_args, MAX_ARGS); (void)dm_strncpy(act->lv_args, r->lv_args, MAX_ARGS);
log_debug("adopt lock for lv %s %s", act->vg_name, act->lv_uuid); log_debug("adopt lock for lv %s %s", act->vg_name, act->lv_uuid);

View File

@ -66,9 +66,9 @@ char devices_file_product_uuid_orig[PATH_MAX];
char *strdup_pvid(char *pvid) char *strdup_pvid(char *pvid)
{ {
char *buf; char *buf;
if (!(buf = zalloc(ID_LEN + 1))) if (!(buf = malloc(ID_LEN + 1)))
return NULL; return NULL;
strncpy(buf, pvid, ID_LEN); (void)dm_strncpy(buf, pvid, ID_LEN + 1);
return buf; return buf;
} }
@ -1235,7 +1235,7 @@ int device_ids_read(struct cmd_context *cmd)
/* Save original for lvmdevices output. */ /* Save original for lvmdevices output. */
if (!strcmp(cmd->name, "lvmdevices")) if (!strcmp(cmd->name, "lvmdevices"))
strncpy(devices_file_hostname_orig, check_id, PATH_MAX-1); (void)dm_strncpy(devices_file_hostname_orig, check_id, PATH_MAX);
if (!cmd->device_ids_check_hostname) if (!cmd->device_ids_check_hostname)
continue; continue;
@ -1255,7 +1255,7 @@ int device_ids_read(struct cmd_context *cmd)
/* Save original for lvmdevices output. */ /* Save original for lvmdevices output. */
if (!strcmp(cmd->name, "lvmdevices")) if (!strcmp(cmd->name, "lvmdevices"))
strncpy(devices_file_product_uuid_orig, check_id, PATH_MAX-1); (void)dm_strncpy(devices_file_product_uuid_orig, check_id, PATH_MAX);
if (!cmd->device_ids_check_product_uuid) if (!cmd->device_ids_check_product_uuid)
continue; continue;
@ -1482,7 +1482,7 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
(de_date < low_date) || (de_date < low_date) ||
(de_date == low_date && de_time < low_time) || (de_date == low_date && de_time < low_time) ||
(de_date == low_date && de_time == low_time && de_count < low_count)) { (de_date == low_date && de_time == low_time && de_count < low_count)) {
strncpy(low_name, de->d_name, sizeof(low_name)); (void)dm_strncpy(low_name, de->d_name, sizeof(low_name));
low_date = de_date; low_date = de_date;
low_time = de_time; low_time = de_time;
low_count = de_count; low_count = de_count;