1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

cleanup: allocate NAME_LEN size for lv name

This commit is contained in:
Zdenek Kabelac 2016-12-13 00:09:38 +01:00
parent d0fe3ec0c5
commit 47b96c3537

View File

@ -548,18 +548,15 @@ static char *_generate_raid_name(struct logical_volume *lv,
const char *suffix, int count)
{
const char *format = (count >= 0) ? "%s_%s_%u" : "%s_%s";
size_t len = strlen(lv->name) + strlen(suffix) + ((count >= 0) ? 5 : 2);
char *name;
char name[NAME_LEN], *lvname;
int historical;
if (!(name = dm_pool_alloc(lv->vg->vgmem, len))) {
log_error("Failed to allocate new name.");
if (dm_snprintf(name, sizeof(name), format, lv->name, suffix, count) < 0) {
log_error("Failed to new raid name for %s.",
display_lvname(lv));
return NULL;
}
if (dm_snprintf(name, len, format, lv->name, suffix, count) < 0)
return_NULL;
if (!validate_name(name)) {
log_error("New logical volume name \"%s\" is not valid.", name);
return NULL;
@ -571,7 +568,12 @@ static char *_generate_raid_name(struct logical_volume *lv,
return NULL;
}
return name;
if (!(lvname = dm_pool_strdup(lv->vg->vgmem, name))) {
log_error("Failed to allocate new name.");
return NULL;
}
return lvname;
}
/*
* Create an LV of specified type. Set visible after creation.