mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
pvmove: fix building sibling raid lv name
Make a local copy of the 'idx' string to avoid overlapping during the rebuild of name. This fixes cases where users specified raid component LVs for moving. Reported-by: kotarou3@github.com
This commit is contained in:
parent
970e4d295e
commit
e2f29c4989
@ -141,6 +141,7 @@ static int _remove_sibling_pvs_from_trim_list(struct logical_volume *lv,
|
||||
char *idx, *suffix;
|
||||
const char *sibling;
|
||||
char sublv_name[NAME_LEN];
|
||||
char idx_buf[16];
|
||||
struct logical_volume *sublv;
|
||||
struct dm_list untrim_list, *pvh1, *pvh2;
|
||||
struct pv_list *pvl1, *pvl2;
|
||||
@ -174,9 +175,15 @@ 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))) {
|
||||
log_error(INTERNAL_ERROR "Unexpected LV index %s.", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create the siblings name (e.g. "raidlv_rmeta_N" -> "raidlv_rimage_N" */
|
||||
if (dm_snprintf(suffix + 2, sizeof(sublv_name) - 2 - (suffix - sublv_name),
|
||||
"%s_%s", sibling, idx) < 0) {
|
||||
"%s_%s", sibling, idx_buf) < 0) {
|
||||
log_error("Raid sublv for name %s too long.", lv_name);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user