mirror of
git://sourceware.org/git/lvm2.git
synced 2025-10-08 19:33:19 +03:00
Compare commits
9 Commits
v2_03_26
...
dev-zkabel
Author | SHA1 | Date | |
---|---|---|---|
|
3777feb7a7 | ||
|
55f33d734f | ||
|
25bf939e31 | ||
|
f0a4888b33 | ||
|
7153a5094d | ||
|
c317554b1d | ||
|
051f9c52c4 | ||
|
17cf661867 | ||
|
8145f8b061 |
@@ -1634,7 +1634,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);
|
||||
(void) dm_strncpy(new->name.value, uuid, size);
|
||||
dm_strncpy(new->name.value, uuid, size);
|
||||
new->name.length = (uint32_t)size;
|
||||
new->luid = luid;
|
||||
|
||||
|
@@ -452,7 +452,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
||||
lc->skip_bit_warning = region_count;
|
||||
lc->disk_fd = -1;
|
||||
lc->log_dev_failed = 0;
|
||||
if (!dm_strncpy(lc->uuid, uuid, DM_UUID_LEN)) {
|
||||
if (!dm_strncpy_check(lc->uuid, uuid, DM_UUID_LEN)) {
|
||||
LOG_ERROR("Cannot use too long UUID %s.", uuid);
|
||||
r = -EINVAL;
|
||||
goto fail;
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#define _LVM_CLOG_FUNCTIONS_H
|
||||
|
||||
#include "libdm/libdevmapper.h"
|
||||
#include "libdm/dm-tools/util.h"
|
||||
#include "libdm/misc/dm-log-userspace.h"
|
||||
#include "cluster.h"
|
||||
|
||||
|
@@ -2367,13 +2367,13 @@ static struct resource *find_resource_act(struct lockspace *ls,
|
||||
r->mode = LD_LK_UN;
|
||||
|
||||
if (r->type == LD_RT_GL) {
|
||||
(void)dm_strncpy(r->name, R_NAME_GL, MAX_NAME);
|
||||
dm_strncpy(r->name, R_NAME_GL, sizeof(r->name));
|
||||
r->use_vb = 1;
|
||||
} else if (r->type == LD_RT_VG) {
|
||||
(void)dm_strncpy(r->name, R_NAME_VG, MAX_NAME);
|
||||
dm_strncpy(r->name, R_NAME_VG, sizeof(r->name));
|
||||
r->use_vb = 1;
|
||||
} else if (r->type == LD_RT_LV) {
|
||||
(void)dm_strncpy(r->name, act->lv_uuid, MAX_NAME);
|
||||
dm_strncpy(r->name, act->lv_uuid, sizeof(r->name));
|
||||
r->use_vb = 0;
|
||||
}
|
||||
|
||||
@@ -3529,7 +3529,7 @@ static void work_test_gl(void)
|
||||
is_enabled = lm_gl_is_enabled(ls);
|
||||
if (is_enabled) {
|
||||
log_debug("S %s worker found gl_is_enabled", ls->name);
|
||||
(void)dm_strncpy(gl_lsname_sanlock, ls->name, MAX_NAME);
|
||||
dm_strncpy(gl_lsname_sanlock, ls->name, sizeof(gl_lsname_sanlock));
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&ls->mutex);
|
||||
@@ -5719,9 +5719,9 @@ static void adopt_locks(void)
|
||||
act->flags = (LD_AF_ADOPT | LD_AF_PERSISTENT);
|
||||
act->client_id = INTERNAL_CLIENT_ID;
|
||||
act->lm_type = ls->lm_type;
|
||||
(void)dm_strncpy(act->vg_name, ls->vg_name, MAX_NAME);
|
||||
(void)dm_strncpy(act->lv_uuid, r->name, MAX_NAME);
|
||||
(void)dm_strncpy(act->lv_args, r->lv_args, MAX_ARGS);
|
||||
dm_strncpy(act->vg_name, ls->vg_name, sizeof(act->vg_name));
|
||||
dm_strncpy(act->lv_uuid, r->name, sizeof(act->lv_uuid));
|
||||
dm_strncpy(act->lv_args, r->lv_args, sizeof(act->lv_args));
|
||||
|
||||
log_debug("adopt lock for lv %s %s", act->vg_name, act->lv_uuid);
|
||||
|
||||
@@ -5747,7 +5747,7 @@ static void adopt_locks(void)
|
||||
act->flags = LD_AF_ADOPT;
|
||||
act->client_id = INTERNAL_CLIENT_ID;
|
||||
act->lm_type = ls->lm_type;
|
||||
(void)dm_strncpy(act->vg_name, ls->vg_name, MAX_NAME);
|
||||
dm_strncpy(act->vg_name, ls->vg_name, sizeof(act->vg_name));
|
||||
|
||||
log_debug("adopt lock for vg %s", act->vg_name);
|
||||
|
||||
|
@@ -848,8 +848,8 @@ int lm_get_lockspaces_dlm(struct list_head *ls_rejoin)
|
||||
}
|
||||
|
||||
ls->lm_type = LD_LM_DLM;
|
||||
(void)dm_strncpy(ls->name, de->d_name, MAX_NAME);
|
||||
(void)dm_strncpy(ls->vg_name, ls->name + strlen(LVM_LS_PREFIX), MAX_NAME);
|
||||
dm_strncpy(ls->name, de->d_name, sizeof(ls->name));
|
||||
dm_strncpy(ls->vg_name, ls->name + strlen(LVM_LS_PREFIX), sizeof(ls->vg_name));
|
||||
list_add_tail(&ls->list, ls_rejoin);
|
||||
}
|
||||
|
||||
@@ -885,7 +885,7 @@ int lm_refresh_lv_start_dlm(struct action *act)
|
||||
int rv;
|
||||
|
||||
/* split /dev/vgname/lvname into vgname and lvname strings */
|
||||
(void)dm_strncpy(path, act->path, PATH_MAX);
|
||||
dm_strncpy(path, act->path, sizeof(path));
|
||||
|
||||
/* skip past dev */
|
||||
if (!(p = strchr(path + 1, '/')))
|
||||
|
@@ -227,6 +227,22 @@ int lm_data_size_sanlock(void)
|
||||
|
||||
static uint64_t daemon_test_lv_count;
|
||||
|
||||
/*
|
||||
* Copy a null-terminated string "str" into a fixed
|
||||
* size struct field "buf" which is not null terminated.
|
||||
* (ATM SANLK_NAME_LEN is only 48 bytes.
|
||||
* Avoid strncpy() for coverity issues.
|
||||
*/
|
||||
static void strcpy_name_len(char *buf, const char *str, size_t len)
|
||||
{
|
||||
size_t l;
|
||||
|
||||
/* copy at most len sized length of str */
|
||||
for (l = 0; l < len; ++l)
|
||||
if (!(buf[l] = str[l]))
|
||||
break;
|
||||
}
|
||||
|
||||
static int lock_lv_name_from_args(char *vg_args, char *lock_lv_name)
|
||||
{
|
||||
return last_string_from_args(vg_args, lock_lv_name);
|
||||
@@ -531,7 +547,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
VG_LOCK_ARGS_MAJOR, VG_LOCK_ARGS_MINOR, VG_LOCK_ARGS_PATCH);
|
||||
|
||||
/* see comment above about input vg_args being only lock_lv_name */
|
||||
(void)dm_strncpy(lock_lv_name, vg_args, sizeof(lock_lv_name));
|
||||
dm_strncpy(lock_lv_name, vg_args, sizeof(lock_lv_name));
|
||||
|
||||
if (strlen(lock_lv_name) + strlen(lock_args_version) + 2 > MAX_ARGS)
|
||||
return -EARGS;
|
||||
@@ -573,7 +589,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
}
|
||||
}
|
||||
|
||||
(void)dm_strncpy(ss.name, ls_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(ss.name, ls_name, SANLK_NAME_LEN);
|
||||
memcpy(ss.host_id_disk.path, disk.path, SANLK_PATH_LEN);
|
||||
ss.host_id_disk.offset = 0;
|
||||
ss.flags = (sector_size == 4096) ? (SANLK_LSF_SECTOR4K | SANLK_LSF_ALIGN8M) :
|
||||
@@ -606,7 +622,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
gl_name = R_NAME_GL;
|
||||
|
||||
memcpy(rd.rs.lockspace_name, ss.name, SANLK_NAME_LEN);
|
||||
(void)dm_strncpy(rd.rs.name, gl_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, gl_name, SANLK_NAME_LEN);
|
||||
memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN);
|
||||
rd.rs.disks[0].offset = align_size * GL_LOCK_BEGIN;
|
||||
rd.rs.num_disks = 1;
|
||||
@@ -621,7 +637,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
}
|
||||
|
||||
memcpy(rd.rs.lockspace_name, ss.name, SANLK_NAME_LEN);
|
||||
(void)dm_strncpy(rd.rs.name, R_NAME_VG, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, R_NAME_VG, SANLK_NAME_LEN);
|
||||
memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN);
|
||||
rd.rs.disks[0].offset = align_size * VG_LOCK_BEGIN;
|
||||
rd.rs.num_disks = 1;
|
||||
@@ -636,7 +652,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
}
|
||||
|
||||
if (!strcmp(gl_name, R_NAME_GL))
|
||||
(void)dm_strncpy(gl_lsname_sanlock, ls_name, MAX_NAME);
|
||||
dm_strncpy(gl_lsname_sanlock, ls_name, sizeof(gl_lsname_sanlock));
|
||||
|
||||
rv = snprintf(vg_args, MAX_ARGS, "%s:%s", lock_args_version, lock_lv_name);
|
||||
if (rv >= MAX_ARGS)
|
||||
@@ -655,8 +671,8 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
|
||||
rd.rs.flags = (sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) :
|
||||
(SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M);
|
||||
memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN);
|
||||
(void)dm_strncpy(rd.rs.lockspace_name, ls_name, SANLK_NAME_LEN);
|
||||
(void)dm_strncpy(rd.rs.name, "#unused", SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.lockspace_name, ls_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, "#unused", SANLK_NAME_LEN);
|
||||
|
||||
offset = align_size * LV_LOCK_BEGIN;
|
||||
|
||||
@@ -724,7 +740,7 @@ int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void)dm_strncpy(rd.rs.lockspace_name, ls_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.lockspace_name, ls_name, SANLK_NAME_LEN);
|
||||
rd.rs.num_disks = 1;
|
||||
if ((rv = build_dm_path(rd.rs.disks[0].path, SANLK_PATH_LEN, vg_name, lock_lv_name)))
|
||||
return rv;
|
||||
@@ -799,7 +815,7 @@ int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name,
|
||||
log_debug("S %s init_lv_san %s found unused area at %llu",
|
||||
ls_name, lv_name, (unsigned long long)offset);
|
||||
|
||||
(void)dm_strncpy(rd.rs.name, lv_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, lv_name, SANLK_NAME_LEN);
|
||||
rd.rs.flags = (sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) :
|
||||
(SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M);
|
||||
|
||||
@@ -898,7 +914,7 @@ int lm_rename_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_
|
||||
if (!sector_size || !align_size)
|
||||
return -1;
|
||||
|
||||
(void)dm_strncpy(ss.name, ls_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(ss.name, ls_name, SANLK_NAME_LEN);
|
||||
|
||||
rv = sanlock_write_lockspace(&ss, 0, 0, sanlock_io_timeout);
|
||||
if (rv < 0) {
|
||||
@@ -1008,7 +1024,7 @@ int lm_free_lv_sanlock(struct lockspace *ls, struct resource *r)
|
||||
if (daemon_test)
|
||||
return 0;
|
||||
|
||||
(void)dm_strncpy(rs->name, "#unused", SANLK_NAME_LEN);
|
||||
strcpy_name_len(rs->name, "#unused", SANLK_NAME_LEN);
|
||||
|
||||
rv = sanlock_write_resource(rs, 0, 0, 0);
|
||||
if (rv < 0) {
|
||||
@@ -1042,11 +1058,11 @@ int lm_ex_disable_gl_sanlock(struct lockspace *ls)
|
||||
memset(&rd1, 0, sizeof(rd1));
|
||||
memset(&rd2, 0, sizeof(rd2));
|
||||
|
||||
(void)dm_strncpy(rd1.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
(void)dm_strncpy(rd1.rs.name, R_NAME_GL, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd1.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd1.rs.name, R_NAME_GL, SANLK_NAME_LEN);
|
||||
|
||||
(void)dm_strncpy(rd2.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
(void)dm_strncpy(rd2.rs.name, R_NAME_GL_DISABLED, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd2.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd2.rs.name, R_NAME_GL_DISABLED, SANLK_NAME_LEN);
|
||||
|
||||
rd1.rs.num_disks = 1;
|
||||
memcpy(rd1.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1);
|
||||
@@ -1111,8 +1127,8 @@ int lm_able_gl_sanlock(struct lockspace *ls, int enable)
|
||||
|
||||
memset(&rd, 0, sizeof(rd));
|
||||
|
||||
(void)dm_strncpy(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
(void)dm_strncpy(rd.rs.name, gl_name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.name, gl_name, SANLK_NAME_LEN);
|
||||
|
||||
rd.rs.num_disks = 1;
|
||||
memcpy(rd.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1);
|
||||
@@ -1132,7 +1148,7 @@ out:
|
||||
ls->sanlock_gl_enabled = enable;
|
||||
|
||||
if (enable)
|
||||
(void)dm_strncpy(gl_lsname_sanlock, ls->name, MAX_NAME);
|
||||
dm_strncpy(gl_lsname_sanlock, ls->name, sizeof(gl_lsname_sanlock));
|
||||
|
||||
if (!enable && !strcmp(gl_lsname_sanlock, ls->name))
|
||||
memset(gl_lsname_sanlock, 0, sizeof(gl_lsname_sanlock));
|
||||
@@ -1152,7 +1168,7 @@ static int gl_is_enabled(struct lockspace *ls, struct lm_sanlock *lms)
|
||||
|
||||
memset(&rd, 0, sizeof(rd));
|
||||
|
||||
(void)dm_strncpy(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
|
||||
/* leave rs.name empty, it is what we're checking */
|
||||
|
||||
@@ -1223,7 +1239,7 @@ int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset, int *
|
||||
|
||||
memset(&rd, 0, sizeof(rd));
|
||||
|
||||
(void)dm_strncpy(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
rd.rs.num_disks = 1;
|
||||
memcpy(rd.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1);
|
||||
rd.rs.flags = (lms->sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) :
|
||||
@@ -1574,7 +1590,7 @@ int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg)
|
||||
* This shouldn't be generally necessary, but there may some races
|
||||
* between nodes starting and removing a vg which this could help.
|
||||
*/
|
||||
(void)dm_strncpy(lms->ss.name, "#unused", SANLK_NAME_LEN);
|
||||
strcpy_name_len(lms->ss.name, "#unused", SANLK_NAME_LEN);
|
||||
|
||||
rv = sanlock_write_lockspace(&lms->ss, 0, 0, sanlock_io_timeout);
|
||||
if (rv < 0) {
|
||||
@@ -1602,8 +1618,8 @@ static int lm_add_resource_sanlock(struct lockspace *ls, struct resource *r)
|
||||
struct lm_sanlock *lms = (struct lm_sanlock *)ls->lm_data;
|
||||
struct rd_sanlock *rds = (struct rd_sanlock *)r->lm_data;
|
||||
|
||||
(void)dm_strncpy(rds->rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
(void)dm_strncpy(rds->rs.name, r->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rds->rs.lockspace_name, ls->name, SANLK_NAME_LEN);
|
||||
strcpy_name_len(rds->rs.name, r->name, SANLK_NAME_LEN);
|
||||
rds->rs.num_disks = 1;
|
||||
memcpy(rds->rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN);
|
||||
rds->rs.flags = (lms->sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M);
|
||||
@@ -2032,7 +2048,7 @@ static int release_rename(struct lockspace *ls, struct resource *r)
|
||||
res1 = (struct sanlk_resource *)&rd1;
|
||||
res2 = (struct sanlk_resource *)&rd2;
|
||||
|
||||
(void)dm_strncpy(res2->name, "invalid_removed", SANLK_NAME_LEN);
|
||||
strcpy_name_len(res2->name, "invalid_removed", SANLK_NAME_LEN);
|
||||
|
||||
res_args[0] = res1;
|
||||
res_args[1] = res2;
|
||||
|
@@ -502,7 +502,7 @@ int driver_version(char *version, size_t size)
|
||||
!dm_driver_version(_vsn, sizeof(_vsn)))
|
||||
return_0;
|
||||
|
||||
(void) dm_strncpy(version, _vsn, size);
|
||||
dm_strncpy(version, _vsn, size);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@@ -641,7 +641,7 @@ static int _is_usable_uuid(const struct device *dev, const char *name, const cha
|
||||
|
||||
/* Recognize some older reserved LVs just from the LV name (snapshot, pvmove...) */
|
||||
vgname = vg_name;
|
||||
if (!dm_strncpy(vg_name, name, sizeof(vg_name)) ||
|
||||
if (!dm_strncpy_check(vg_name, name, sizeof(vg_name)) ||
|
||||
!dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer))
|
||||
return_0;
|
||||
|
||||
@@ -871,7 +871,7 @@ static int _info(struct cmd_context *cmd,
|
||||
if (strcmp(suffix_position + 1, suffix))
|
||||
continue;
|
||||
|
||||
(void) dm_strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
|
||||
dm_strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
|
||||
if (!_info_run(old_style_dlid, dminfo, read_ahead, seg_status,
|
||||
name_check, with_open_count, with_read_ahead,
|
||||
0, 0))
|
||||
@@ -2315,7 +2315,7 @@ static int _check_holder(struct dev_manager *dm, struct dm_tree *dtree,
|
||||
if (!memcmp(uuid, &lv->vg->id, ID_LEN) &&
|
||||
!dm_tree_find_node_by_uuid(dtree, uuid)) {
|
||||
/* trims any UUID suffix (i.e. -cow) */
|
||||
(void) dm_strncpy((char*)&id, uuid, 2 * sizeof(struct id) + 1);
|
||||
dm_strncpy((char*)&id, uuid, 2 * sizeof(struct id) + 1);
|
||||
|
||||
/* If UUID is not yet in dtree, look for matching LV */
|
||||
if (!(lv_det = find_lv_in_vg_by_lvid(lv->vg, &id))) {
|
||||
@@ -2676,24 +2676,29 @@ static int _pool_register_callback(struct dev_manager *dm,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct id _get_id_for_meta_or_data(const struct lv_segment *lvseg, int meta_or_data)
|
||||
{
|
||||
/* When ID is provided in form of metadata_id or data_id, otherwise use CVOL ID */
|
||||
if (meta_or_data && lvseg->metadata_id)
|
||||
return *lvseg->metadata_id;
|
||||
|
||||
if (!meta_or_data && lvseg->data_id)
|
||||
return *lvseg->data_id;
|
||||
|
||||
return lvseg->pool_lv->lvid.id[1];
|
||||
}
|
||||
|
||||
/* Add special devices _cmeta & _cdata on top of CacheVol to dm tree */
|
||||
static int _add_cvol_subdev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
||||
const struct logical_volume *lv, int meta_or_data)
|
||||
{
|
||||
const char *layer = meta_or_data ? "cmeta" : "cdata";
|
||||
struct dm_pool *mem = dm->track_pending_delete ? dm->cmd->pending_delete_mem : dm->mem;
|
||||
const struct logical_volume *pool_lv = first_seg(lv)->pool_lv;
|
||||
struct lv_segment *lvseg = first_seg(lv);
|
||||
const struct logical_volume *pool_lv = lvseg->pool_lv;
|
||||
struct dm_info info;
|
||||
char *name ,*dlid;
|
||||
union lvid lvid = {
|
||||
{
|
||||
lv->vg->id,
|
||||
/* When ID is provided in form of metadata_id or data_id, otherwise use CVOL ID */
|
||||
(meta_or_data && lvseg->metadata_id) ? *lvseg->metadata_id :
|
||||
(lvseg->data_id) ? *lvseg->data_id : pool_lv->lvid.id[1]
|
||||
}
|
||||
};
|
||||
union lvid lvid = { { lv->vg->id, _get_id_for_meta_or_data(lvseg, meta_or_data) } };
|
||||
|
||||
if (!(dlid = dm_build_dm_uuid(mem, UUID_PREFIX, (const char *)&lvid.s, layer)))
|
||||
return_0;
|
||||
@@ -3346,14 +3351,7 @@ static int _add_new_cvol_subdev_to_dtree(struct dev_manager *dm,
|
||||
const struct logical_volume *pool_lv = lvseg->pool_lv;
|
||||
struct dm_tree_node *dnode;
|
||||
char *dlid, *dlid_pool, *name;
|
||||
union lvid lvid = {
|
||||
{
|
||||
lv->vg->id,
|
||||
/* When ID is provided in form of metadata_id or data_id, otherwise use CVOL ID */
|
||||
(meta_or_data && lvseg->metadata_id) ? *lvseg->metadata_id :
|
||||
(lvseg->data_id) ? *lvseg->data_id : pool_lv->lvid.id[1]
|
||||
}
|
||||
};
|
||||
union lvid lvid = { { lv->vg->id, _get_id_for_meta_or_data(lvseg, meta_or_data) } };
|
||||
|
||||
if (!(dlid = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid.s, layer)))
|
||||
return_0;
|
||||
|
@@ -252,7 +252,7 @@ static void _get_sysfs_dir(struct cmd_context *cmd, char *buf, size_t buf_size)
|
||||
return;
|
||||
}
|
||||
|
||||
(void) dm_strncpy(buf, sys_mnt, buf_size);
|
||||
dm_strncpy(buf, sys_mnt, buf_size);
|
||||
}
|
||||
|
||||
static uint32_t _parse_debug_fields(struct cmd_context *cmd, int cfg, const char *cfgname)
|
||||
|
@@ -283,8 +283,8 @@ static int _compare_paths(const char *path0, const char *path1)
|
||||
if (slash1 < slash0)
|
||||
return 1;
|
||||
|
||||
(void) dm_strncpy(p0, path0, sizeof(p0));
|
||||
(void) dm_strncpy(p1, path1, sizeof(p1));
|
||||
dm_strncpy(p0, path0, sizeof(p0));
|
||||
dm_strncpy(p1, path1, sizeof(p1));
|
||||
s0 = p0 + 1;
|
||||
s1 = p1 + 1;
|
||||
|
||||
@@ -861,7 +861,7 @@ static int _insert_dir(const char *dir)
|
||||
char path[PATH_MAX];
|
||||
size_t len;
|
||||
|
||||
if (!dm_strncpy(path, dir, sizeof(path) - 1)) {
|
||||
if (!dm_strncpy_check(path, dir, sizeof(path))) {
|
||||
log_debug_devs("Dir path %s is too long", path);
|
||||
return 0;
|
||||
}
|
||||
@@ -876,7 +876,7 @@ static int _insert_dir(const char *dir)
|
||||
if (dirent[n]->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
if (!dm_strncpy(path + len, dirent[n]->d_name, sizeof(path) - len)) {
|
||||
if (!dm_strncpy_check(path + len, dirent[n]->d_name, sizeof(path) - len)) {
|
||||
log_debug_devs("Path %s/%s is too long.", dir, dirent[n]->d_name);
|
||||
r = 0;
|
||||
continue;
|
||||
@@ -1810,7 +1810,7 @@ static int _setup_devices_file_dmeventd(struct cmd_context *cmd)
|
||||
return 0;
|
||||
|
||||
cmd->enable_devices_file = 1;
|
||||
(void) dm_strncpy(cmd->devices_file_path, path, sizeof(cmd->devices_file_path));
|
||||
dm_strncpy(cmd->devices_file_path, path, sizeof(cmd->devices_file_path));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -68,7 +68,7 @@ char *strdup_pvid(char *pvid)
|
||||
char *buf;
|
||||
if (!(buf = zalloc(ID_LEN + 1)))
|
||||
return_NULL;
|
||||
(void)dm_strncpy(buf, pvid, ID_LEN + 1);
|
||||
dm_strncpy(buf, pvid, ID_LEN + 1);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -626,7 +626,8 @@ struct dev_wwid *dev_add_wwid(char *id, int id_type, struct dm_list *ids)
|
||||
|
||||
if (!(dw = zalloc(sizeof(*dw))))
|
||||
return_NULL;
|
||||
(void)dm_strncpy(dw->id, id, sizeof(dw->id));
|
||||
/* Copy id string with upto DEV_WWID_SIZE characters */
|
||||
dm_strncpy(dw->id, id, sizeof(dw->id));
|
||||
dw->type = id_type;
|
||||
dm_list_add(ids, &dw->list);
|
||||
return dw;
|
||||
@@ -1244,7 +1245,7 @@ int device_ids_read(struct cmd_context *cmd)
|
||||
|
||||
/* Save original for lvmdevices output. */
|
||||
if (!strcmp(cmd->name, "lvmdevices"))
|
||||
(void)dm_strncpy(devices_file_hostname_orig, check_id, PATH_MAX);
|
||||
dm_strncpy(devices_file_hostname_orig, check_id, sizeof(devices_file_hostname_orig));
|
||||
|
||||
if (!cmd->device_ids_check_hostname)
|
||||
continue;
|
||||
@@ -1264,7 +1265,7 @@ int device_ids_read(struct cmd_context *cmd)
|
||||
|
||||
/* Save original for lvmdevices output. */
|
||||
if (!strcmp(cmd->name, "lvmdevices"))
|
||||
(void)dm_strncpy(devices_file_product_uuid_orig, check_id, PATH_MAX);
|
||||
dm_strncpy(devices_file_product_uuid_orig, check_id, sizeof(devices_file_product_uuid_orig));
|
||||
|
||||
if (!cmd->device_ids_check_product_uuid)
|
||||
continue;
|
||||
@@ -1487,7 +1488,7 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
|
||||
(de_date < low_date) ||
|
||||
(de_date == low_date && de_time < low_time) ||
|
||||
(de_date == low_date && de_time == low_time && de_count < low_count)) {
|
||||
(void)dm_strncpy(low_name, de->d_name, sizeof(low_name));
|
||||
dm_strncpy(low_name, de->d_name, sizeof(low_name));
|
||||
low_date = de_date;
|
||||
low_time = de_time;
|
||||
low_count = de_count;
|
||||
|
@@ -278,7 +278,7 @@ int fs_mount_state_is_misnamed(struct cmd_context *cmd, struct logical_volume *l
|
||||
continue;
|
||||
if (stme.st_dev != st_lv.st_rdev)
|
||||
continue;
|
||||
if (!dm_strncpy(mtab_mntpath, me->mnt_dir, sizeof(mtab_mntpath)))
|
||||
if (!dm_strncpy_check(mtab_mntpath, me->mnt_dir, sizeof(mtab_mntpath)))
|
||||
continue; /* Ignore too long unsupported paths */
|
||||
break;
|
||||
}
|
||||
|
@@ -181,9 +181,9 @@ int get_pvs_online(struct dm_list *pvs_online, const char *vgname)
|
||||
if (file_major || file_minor)
|
||||
po->devno = MKDEV(file_major, file_minor);
|
||||
if (file_vgname[0])
|
||||
(void)dm_strncpy(po->vgname, file_vgname, sizeof(po->vgname));
|
||||
dm_strncpy(po->vgname, file_vgname, sizeof(po->vgname));
|
||||
if (file_devname[0])
|
||||
(void)dm_strncpy(po->devname, file_devname, sizeof(po->devname));
|
||||
dm_strncpy(po->devname, file_devname, sizeof(po->devname));
|
||||
|
||||
log_debug("Found PV online %s for VG %s %s", path, vgname, file_devname);
|
||||
dm_list_add(pvs_online, &po->list);
|
||||
|
@@ -79,7 +79,7 @@ static int _split_vg(const char *filename, char *vgname, size_t vgsize,
|
||||
if (vg_len + 1 > vgsize)
|
||||
return 0;
|
||||
|
||||
(void) dm_strncpy(vgname, filename, vg_len + 1);
|
||||
dm_strncpy(vgname, filename, vg_len + 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@@ -1305,8 +1305,8 @@ static int _vg_write_file(struct format_instance *fid __attribute__((unused)),
|
||||
if (slash == 0)
|
||||
strcpy(temp_dir, ".");
|
||||
else if (slash - tc->path_edit < PATH_MAX) {
|
||||
(void) dm_strncpy(temp_dir, tc->path_edit,
|
||||
(size_t) (slash - tc->path_edit + 1));
|
||||
dm_strncpy(temp_dir, tc->path_edit,
|
||||
(size_t) (slash - tc->path_edit + 1));
|
||||
} else {
|
||||
log_error("Text format failed to determine directory.");
|
||||
return 0;
|
||||
|
@@ -837,18 +837,18 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int *
|
||||
vgname = split[3];
|
||||
|
||||
if (name && !strncmp(name, "scan:", 5))
|
||||
if (!dm_strncpy(hint.name, name + 5, sizeof(hint.name)))
|
||||
if (!dm_strncpy_check(hint.name, name + 5, sizeof(hint.name)))
|
||||
continue;
|
||||
|
||||
if (pvid && !strncmp(pvid, "pvid:", 5))
|
||||
if (!dm_strncpy(hint.pvid, pvid + 5, sizeof(hint.pvid)))
|
||||
if (!dm_strncpy_check(hint.pvid, pvid + 5, sizeof(hint.pvid)))
|
||||
continue;
|
||||
|
||||
if (devn && sscanf(devn, "devn:%d:%d", &major, &minor) == 2)
|
||||
hint.devt = makedev(major, minor);
|
||||
|
||||
if (vgname && (strlen(vgname) > 3) && (vgname[4] != '-'))
|
||||
if (!dm_strncpy(hint.vgname, vgname + 3, sizeof(hint.vgname)))
|
||||
if (!dm_strncpy_check(hint.vgname, vgname + 3, sizeof(hint.vgname)))
|
||||
continue;
|
||||
|
||||
if (!(alloc_hint = zalloc(sizeof(struct hint)))) {
|
||||
@@ -886,7 +886,7 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int *
|
||||
if (!_dev_in_hint_hash(cmd, dev))
|
||||
continue;
|
||||
|
||||
(void) dm_strncpy(devpath, dev_name(dev), sizeof(devpath));
|
||||
dm_strncpy(devpath, dev_name(dev), sizeof(devpath));
|
||||
calc_hash = calc_crc(calc_hash, (const uint8_t *)devpath, strlen(devpath));
|
||||
calc_count++;
|
||||
}
|
||||
@@ -1077,7 +1077,7 @@ int write_hint_file(struct cmd_context *cmd, int newhints)
|
||||
* detect when the devices on the system change, which
|
||||
* invalidates the existing hints.
|
||||
*/
|
||||
(void) dm_strncpy(devpath, dev_name(dev), sizeof(devpath));
|
||||
dm_strncpy(devpath, dev_name(dev), sizeof(devpath));
|
||||
hash = calc_crc(hash, (const uint8_t *)devpath, strlen(devpath));
|
||||
count++;
|
||||
|
||||
|
@@ -77,7 +77,7 @@ int init_file_locking(struct locking_type *locking, struct cmd_context *cmd,
|
||||
|
||||
/* Get lockfile directory from config file */
|
||||
locking_dir = find_config_tree_str(cmd, global_locking_dir_CFG, NULL);
|
||||
if (!dm_strncpy(_lock_dir, locking_dir, sizeof(_lock_dir))) {
|
||||
if (!dm_strncpy_check(_lock_dir, locking_dir, sizeof(_lock_dir))) {
|
||||
log_error("Path for locking_dir %s is invalid.", locking_dir);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -206,7 +206,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str
|
||||
if (!_blocking_supported)
|
||||
flags |= LCK_NONBLOCK;
|
||||
|
||||
if (!dm_strncpy(resource, vol, sizeof(resource))) {
|
||||
if (!dm_strncpy_check(resource, vol, sizeof(resource))) {
|
||||
log_error(INTERNAL_ERROR "Resource name %s is too long.", vol);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -391,7 +391,7 @@ void init_msg_prefix(const char *prefix)
|
||||
{
|
||||
if (prefix)
|
||||
/* Cut away too long prefix */
|
||||
(void) dm_strncpy(_msg_prefix, prefix, sizeof(_msg_prefix));
|
||||
dm_strncpy(_msg_prefix, prefix, sizeof(_msg_prefix));
|
||||
}
|
||||
|
||||
void init_indent(int indent)
|
||||
|
@@ -887,7 +887,7 @@ int vg_remove_pool_metadata_spare(struct volume_group *vg)
|
||||
lv_set_visible(lv);
|
||||
|
||||
/* Cut off suffix _pmspare */
|
||||
if (!dm_strncpy(new_name, lv->name, sizeof(new_name)) ||
|
||||
if (!dm_strncpy_check(new_name, lv->name, sizeof(new_name)) ||
|
||||
!(c = strchr(new_name, '_'))) {
|
||||
log_error(INTERNAL_ERROR "LV %s has no suffix for pool metadata spare.",
|
||||
display_lvname(lv));
|
||||
|
@@ -681,7 +681,7 @@ static int _get_memory_info(uint64_t *total_mb, uint64_t *available_mb)
|
||||
if ((unsigned)(++e - line) > sizeof(namebuf))
|
||||
continue; // something too long
|
||||
|
||||
(void)dm_strncpy((char*)findme.name, line, e - line);
|
||||
dm_strncpy((char*)findme.name, line, e - line);
|
||||
|
||||
found = bsearch(&findme, mt, DM_ARRAY_SIZE(mt), sizeof(mem_table_t),
|
||||
_compare_mem_table_s);
|
||||
|
@@ -146,7 +146,7 @@ static void _rename_detached_cvol(struct cmd_context *cmd, struct logical_volume
|
||||
* Failing to rename is not really a problem, so we intentionally
|
||||
* do not consider some things here as errors.
|
||||
*/
|
||||
if (!dm_strncpy(cvol_name, lv_fast->name, sizeof(cvol_name)) ||
|
||||
if (!dm_strncpy_check(cvol_name, lv_fast->name, sizeof(cvol_name)) ||
|
||||
!(suffix = strstr(cvol_name, "_cvol"))) {
|
||||
log_debug("LV %s has no suffix for cachevol (skipping rename).",
|
||||
display_lvname(lv_fast));
|
||||
|
@@ -164,7 +164,7 @@ void init_log_command(int log_name, int log_pid)
|
||||
return;
|
||||
|
||||
else if (log_name && !log_pid)
|
||||
(void) dm_strncpy(_log_command_info, _cmd_name, sizeof(_log_command_info));
|
||||
dm_strncpy(_log_command_info, _cmd_name, sizeof(_log_command_info));
|
||||
|
||||
else if (!log_name && log_pid)
|
||||
(void) dm_snprintf(_log_command_info, sizeof(_log_command_info), "%d", getpid());
|
||||
@@ -212,7 +212,7 @@ void init_pv_min_size(uint64_t sectors)
|
||||
|
||||
void set_cmd_name(const char *cmd)
|
||||
{
|
||||
(void) dm_strncpy(_cmd_name, cmd, sizeof(_cmd_name));
|
||||
dm_strncpy(_cmd_name, cmd, sizeof(_cmd_name));
|
||||
}
|
||||
|
||||
const char *get_cmd_name(void)
|
||||
@@ -222,7 +222,7 @@ const char *get_cmd_name(void)
|
||||
|
||||
void set_sysfs_dir_path(const char *path)
|
||||
{
|
||||
(void) dm_strncpy(_sysfs_dir_path, path, sizeof(_sysfs_dir_path));
|
||||
dm_strncpy(_sysfs_dir_path, path, sizeof(_sysfs_dir_path));
|
||||
}
|
||||
|
||||
const char *log_command_info(void)
|
||||
|
@@ -302,7 +302,7 @@ int drop_lvname_suffix(char *new_name, const char *name, const char *suffix)
|
||||
{
|
||||
char *c;
|
||||
|
||||
if (!dm_strncpy(new_name, name, NAME_LEN)) {
|
||||
if (!dm_strncpy_check(new_name, name, NAME_LEN)) {
|
||||
log_debug(INTERNAL_ERROR "Name is too long.");
|
||||
return 0;
|
||||
}
|
||||
|
@@ -37,6 +37,6 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname,
|
||||
!(cmd->lib_dir = find_config_tree_str(cmd, global_library_dir_CFG, NULL))) ||
|
||||
(dm_snprintf(path, path_len, "%s/%s", cmd->lib_dir,
|
||||
libname) == -1) || stat(path, &info) == -1) {
|
||||
(void) dm_strncpy(path, libname, path_len);
|
||||
dm_strncpy(path, libname, path_len);
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,12 @@
|
||||
#define uninitialized_var(x) x = x
|
||||
#endif
|
||||
|
||||
/* Use wrapper for checked results */
|
||||
static inline __attribute__((warn_unused_result))
|
||||
int dm_strncpy_check(char *dest, const char *src, size_t n) {
|
||||
return dm_strncpy(dest, src, n);
|
||||
}
|
||||
|
||||
/*
|
||||
* GCC 3.4 adds a __builtin_clz, which uses the count leading zeros (clz)
|
||||
* instruction on arches that have one. Provide a fallback using shifts
|
||||
|
@@ -127,7 +127,7 @@ int id_write_format(const struct id *id, char *buffer, size_t size)
|
||||
assert(ID_LEN == 32);
|
||||
|
||||
if (id->uuid[0] == '#') {
|
||||
(void) dm_strncpy(buffer, (char*)id->uuid, size);
|
||||
dm_strncpy(buffer, (char*)id->uuid, size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ daemon_handle daemon_open(daemon_info i)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!dm_strncpy(sockaddr.sun_path, i.socket, sizeof(sockaddr.sun_path))) {
|
||||
if (!dm_strncpy_check(sockaddr.sun_path, i.socket, sizeof(sockaddr.sun_path))) {
|
||||
log_error("%s: Daemon socket path too long.", i.socket);
|
||||
goto error;
|
||||
}
|
||||
|
@@ -249,7 +249,7 @@ static int _open_socket(daemon_state s)
|
||||
fprintf(stderr, "setting O_NONBLOCK on socket fd %d failed: %s\n", fd, strerror(errno));
|
||||
|
||||
fprintf(stderr, "[D] creating %s\n", s.socket_path);
|
||||
if (!dm_strncpy(sockaddr.sun_path, s.socket_path, sizeof(sockaddr.sun_path))) {
|
||||
if (!dm_strncpy_check(sockaddr.sun_path, s.socket_path, sizeof(sockaddr.sun_path))) {
|
||||
fprintf(stderr, "%s: daemon socket path too long.\n", s.socket_path);
|
||||
goto error;
|
||||
}
|
||||
|
@@ -14,8 +14,8 @@
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
#include "libdm/misc/dm-logging.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@@ -6608,7 +6608,7 @@ static char *_parse_loop_device_name(const char *dev, const char *dev_dir)
|
||||
device[strlen(dev_dir)] != '/')
|
||||
goto_bad;
|
||||
|
||||
if (!dm_strncpy(buf, strrchr(device, '/') + 1, PATH_MAX))
|
||||
if (!dm_strncpy_check(buf, strrchr(device, '/') + 1, PATH_MAX))
|
||||
goto_bad;
|
||||
free(device);
|
||||
} else {
|
||||
@@ -6616,7 +6616,7 @@ static char *_parse_loop_device_name(const char *dev, const char *dev_dir)
|
||||
if (strncmp(dev, "loop", sizeof("loop") - 1))
|
||||
goto_bad;
|
||||
|
||||
if (!dm_strncpy(buf, dev, PATH_MAX))
|
||||
if (!dm_strncpy_check(buf, dev, PATH_MAX))
|
||||
goto_bad;
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,13 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/* Use wrapper for checked results */
|
||||
static inline __attribute__((warn_unused_result))
|
||||
int dm_strncpy_check(char *dest, const char *src, size_t n)
|
||||
{
|
||||
return dm_strncpy(dest, src, n);
|
||||
}
|
||||
|
||||
#define min(a, b) ({ typeof(a) _a = (a); \
|
||||
typeof(b) _b = (b); \
|
||||
(void) (&_a == &_b); \
|
||||
|
@@ -1916,7 +1916,7 @@ static char *_build_group_tag(struct dm_stats *dms, uint64_t group_id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!dm_strncpy(buf, DMS_GROUP_TAG, DMS_GROUP_TAG_LEN + 1))
|
||||
if (!dm_strncpy_check(buf, DMS_GROUP_TAG, DMS_GROUP_TAG_LEN + 1))
|
||||
goto_bad;
|
||||
|
||||
buf += DMS_GROUP_TAG_LEN;
|
||||
|
@@ -92,9 +92,8 @@
|
||||
#define DM_EXPORT_SYMBOL_BASE(func)
|
||||
#endif
|
||||
|
||||
#include "libdm/dm-tools/util.h"
|
||||
|
||||
#include "libdm/libdevmapper.h"
|
||||
#include "libdm/dm-tools/util.h"
|
||||
#include "libdm/misc/dm-logging.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
@@ -59,7 +59,7 @@ test -f "lib/flavour-$LVM_TEST_FLAVOUR" || { echo "NOTE: Flavour '$LVM_TEST_FLAV
|
||||
test -n "$SKIP_WITHOUT_CLVMD" && test "$LVM_TEST_LOCKING" -ne 3 && initskip
|
||||
test -n "$SKIP_WITH_CLVMD" && test "$LVM_TEST_LOCKING" = 3 && initskip
|
||||
|
||||
test -n "$SKIP_WITH_LVMPOLLD" && test -n "$LVM_TEST_LVMPOLLD" && test -z "$LVM_TEST_LVMLOCKD" && initskip
|
||||
test -n "$SKIP_WITH_LVMPOLLD" && test -n "$LVM_TEST_LVMPOLLD" && initskip
|
||||
|
||||
test -n "$SKIP_WITH_LVMLOCKD" && test -n "$LVM_TEST_LVMLOCKD" && initskip
|
||||
|
||||
|
@@ -64,6 +64,9 @@ static int dm_strncpy(char *dest, const char *src, size_t n)
|
||||
|
||||
return 0;
|
||||
}
|
||||
static inline int dm_strncpy_check(char *dest, const char *src, size_t n) {
|
||||
return dm_strncpy(dest, src, n);
|
||||
}
|
||||
|
||||
static char *dm_pool_strdup(void *p, const char *str)
|
||||
{
|
||||
@@ -347,7 +350,7 @@ static int _val_str_to_num(char *str)
|
||||
|
||||
/* compare the name before any suffix like _new or _<lvtype> */
|
||||
|
||||
if (!dm_strncpy(name, str, sizeof(name)))
|
||||
if (!dm_strncpy_check(name, str, sizeof(name)))
|
||||
return 0; /* Buffer is too short */
|
||||
|
||||
if ((new = strchr(name, '_')))
|
||||
@@ -374,7 +377,7 @@ static int _opt_str_to_num(struct command *cmd, const char *str)
|
||||
int i;
|
||||
int first = 0, last = ARG_COUNT - 1, middle;
|
||||
|
||||
if (!dm_strncpy(long_name, str, sizeof(long_name)))
|
||||
if (!dm_strncpy_check(long_name, str, sizeof(long_name)))
|
||||
goto err;
|
||||
|
||||
if ((p = strstr(long_name, "_long")))
|
||||
@@ -507,7 +510,7 @@ static uint64_t _lv_to_bits(struct command *cmd, char *name)
|
||||
int argc;
|
||||
int i;
|
||||
|
||||
(void) dm_strncpy(buf, name, LVTYPE_LEN);
|
||||
dm_strncpy(buf, name, sizeof(buf));
|
||||
|
||||
_split_line(buf, &argc, argv, '_');
|
||||
|
||||
@@ -853,7 +856,7 @@ static char *_get_oo_line(const char *str)
|
||||
char str2[OO_NAME_LEN];
|
||||
int i;
|
||||
|
||||
(void) dm_strncpy(str2, str, sizeof(str2));
|
||||
dm_strncpy(str2, str, sizeof(str2));
|
||||
if ((end = strchr(str2, ':')))
|
||||
*end = '\0';
|
||||
if ((end = strchr(str2, ',')))
|
||||
@@ -1171,7 +1174,7 @@ static void _include_required_opt_args(struct cmd_context *cmdtool, struct comma
|
||||
static void _add_required_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int takes_arg;
|
||||
int takes_arg = 0;
|
||||
int prev_was_opt = 0, prev_was_pos = 0;
|
||||
int orig_ro_count = 0;
|
||||
|
||||
|
@@ -1170,7 +1170,7 @@ static int _raid_split_image_conversion(struct logical_volume *lv)
|
||||
|
||||
if (lv_is_raid_image(lv) &&
|
||||
(s = strstr(lv->name, "_rimage_"))) {
|
||||
(void) dm_strncpy(raidlv_name, lv->name, s - lv->name);
|
||||
dm_strncpy(raidlv_name, lv->name, s - lv->name);
|
||||
|
||||
if (!(tmp_lv = find_lv(lv->vg, raidlv_name))) {
|
||||
log_error("Failed to find RaidLV of RAID subvolume %s.",
|
||||
|
@@ -155,7 +155,7 @@ static int _remove_sibling_pvs_from_trim_list(struct logical_volume *lv,
|
||||
|
||||
dm_list_init(&untrim_list);
|
||||
|
||||
if (!dm_strncpy(sublv_name, lv_name, sizeof(sublv_name))) {
|
||||
if (!dm_strncpy_check(sublv_name, lv_name, sizeof(sublv_name))) {
|
||||
log_error(INTERNAL_ERROR "LV name %s is too long.", lv_name);
|
||||
return 0;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ static int _remove_sibling_pvs_from_trim_list(struct logical_volume *lv,
|
||||
idx++;
|
||||
|
||||
/* Copy idx to local buffer */
|
||||
if (!dm_strncpy(idx_buf, idx, sizeof(idx_buf))) {
|
||||
if (!dm_strncpy_check(idx_buf, idx, sizeof(idx_buf))) {
|
||||
log_error(INTERNAL_ERROR "Unexpected LV index %s.", idx);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1059,7 +1059,7 @@ static int _set_report_prefix_and_name(struct report_args *args,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!dm_strncpy(single_args->report_prefix, report_prefix, sizeof(single_args->report_prefix))) {
|
||||
if (!dm_strncpy_check(single_args->report_prefix, report_prefix, sizeof(single_args->report_prefix))) {
|
||||
log_error("_set_report_prefix_and_name: dm_strncpy failed");
|
||||
return 0;
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ static int _check_all_dm_devices(const char *vg_name, unsigned *found)
|
||||
do {
|
||||
/* TODO: Do we want to validate UUID LVM- prefix as well ? */
|
||||
names = (struct dm_names *)((char *) names + next);
|
||||
if (!dm_strncpy(vgname_buf, names->name, sizeof(vgname_buf))) {
|
||||
if (!dm_strncpy_check(vgname_buf, names->name, sizeof(vgname_buf))) {
|
||||
r = 0;
|
||||
goto_out;
|
||||
}
|
||||
|
@@ -408,7 +408,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
if (strcmp(vgname, vp.old_vgname)) {
|
||||
(void) dm_strncpy(tmp_vgname, base_vgname, NAME_LEN);
|
||||
dm_strncpy(tmp_vgname, base_vgname, sizeof(tmp_vgname));
|
||||
vgname_count = 0;
|
||||
} else {
|
||||
/* Needed when basename matches old name, and PV is not a duplicate
|
||||
|
Reference in New Issue
Block a user