1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

vg_validate: check size of lv_name + vg_name

Since the whole dm device name may not exceed 127 characters,
validate no LV names is bigger then this limit.
This commit is contained in:
Zdenek Kabelac 2014-03-31 11:51:50 +02:00
parent 6570d36ad5
commit 84beba5d7f
2 changed files with 12 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
Extend internal validation of lv names size is less then 128 chars.
Fail in resume for lvrename will result in failing command.
Validate length of new LV name in lvrename to not exceed 127 characters.
Add explict error message when using lvdisplay -c -m.

View File

@ -2336,6 +2336,8 @@ int vg_validate(struct volume_group *vg)
unsigned pv_count = 0;
unsigned num_snapshots = 0;
unsigned spare_count = 0;
size_t vg_name_len = strlen(vg->name);
size_t dev_name_len;
struct validate_hash vhash = { NULL };
if (vg->alloc == ALLOC_CLING_BY_TAGS) {
@ -2417,6 +2419,15 @@ int vg_validate(struct volume_group *vg)
dm_list_iterate_items(lvl, &vg->lvs) {
lv_count++;
dev_name_len = strlen(lvl->lv->name) + vg_name_len + 3;
if (dev_name_len >= NAME_LEN) {
log_error(INTERNAL_ERROR "LV name \"%s/%s\" length %"
PRIsize_t " is not supported.",
vg->name, lvl->lv->name, dev_name_len);
r = 0;
}
if (lv_is_cow(lvl->lv))
num_snapshots++;