mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
Replace dm_snprintf with strncpy
My previous patch fixed incorrect error check for dm_snprintf. However in this particular case - dm_snprintf has been used differently - just like strncpy + setting last char with '\0' - so the code had to return error - because the buffer was to short for whole string. Patch replaces it with real strncpy. Also test for alloca() failure is removed - as the program behaviour is rather undefined in this case - it never returns NULL.
This commit is contained in:
parent
192ec18c76
commit
96077265c4
@ -1785,13 +1785,10 @@ static struct logical_volume *_set_up_mirror_log(struct cmd_context *cmd,
|
|||||||
lv_name = lv->name;
|
lv_name = lv->name;
|
||||||
suffix = "_mlogtmp_%d";
|
suffix = "_mlogtmp_%d";
|
||||||
} else if ((lv_name = strstr(lv->name, MIRROR_SYNC_LAYER))) {
|
} else if ((lv_name = strstr(lv->name, MIRROR_SYNC_LAYER))) {
|
||||||
len = lv_name - lv->name + 1;
|
len = lv_name - lv->name;
|
||||||
if (!(tmp_name = alloca(len)) ||
|
tmp_name = alloca(len + 1);
|
||||||
(dm_snprintf(tmp_name, len, "%s", lv->name) < 0)) {
|
tmp_name[len] = '\0';
|
||||||
log_error("mirror log name allocation failed");
|
lv_name = strncpy(tmp_name, lv->name, len);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
lv_name = tmp_name;
|
|
||||||
suffix = "_mlog";
|
suffix = "_mlog";
|
||||||
} else {
|
} else {
|
||||||
lv_name = lv->name;
|
lv_name = lv->name;
|
||||||
|
Loading…
Reference in New Issue
Block a user