1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +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:
Zdenek Kabelac 2011-04-12 14:13:17 +00:00
parent 192ec18c76
commit 96077265c4

View File

@ -1785,13 +1785,10 @@ static struct logical_volume *_set_up_mirror_log(struct cmd_context *cmd,
lv_name = lv->name;
suffix = "_mlogtmp_%d";
} else if ((lv_name = strstr(lv->name, MIRROR_SYNC_LAYER))) {
len = lv_name - lv->name + 1;
if (!(tmp_name = alloca(len)) ||
(dm_snprintf(tmp_name, len, "%s", lv->name) < 0)) {
log_error("mirror log name allocation failed");
return 0;
}
lv_name = tmp_name;
len = lv_name - lv->name;
tmp_name = alloca(len + 1);
tmp_name[len] = '\0';
lv_name = strncpy(tmp_name, lv->name, len);
suffix = "_mlog";
} else {
lv_name = lv->name;