mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Fix allocation of system_id
As code uses strncpy(system_id, NAME_LEN) and doesn't set '\0' Fix it by always allocating NAME_LEN + 1 buffer size and with zalloc we always get '\0' as the last byte. This bug may trigger some unexpected behavior of the string operation code - depends on the pool allocator. FIXME: refactor this code to alloc_vg.
This commit is contained in:
parent
e1cb521dd9
commit
844b75f4d6
@ -1,5 +1,6 @@
|
||||
Version 2.02.85 -
|
||||
===================================
|
||||
Fix allocation of system_id buffer in volume_group structure.
|
||||
Fix buffer allocation in build_dm_uuid().
|
||||
Fix readlink usage inside get_primary_dev().
|
||||
Use format instance mempool where possible and adequate.
|
||||
|
@ -225,7 +225,7 @@ int import_vg(struct dm_pool *mem,
|
||||
if (!(vg->name = dm_pool_strdup(mem, (char *)dl->pvd.vg_name)))
|
||||
return_0;
|
||||
|
||||
if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN)))
|
||||
if (!(vg->system_id = dm_pool_zalloc(mem, NAME_LEN + 1)))
|
||||
return_0;
|
||||
|
||||
*vg->system_id = '\0';
|
||||
|
@ -666,7 +666,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
|
||||
if (!(vg = alloc_vg("read_vg", fid->fmt->cmd, vgn->key)))
|
||||
return_NULL;
|
||||
|
||||
if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN)))
|
||||
if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
|
||||
goto_bad;
|
||||
|
||||
vgn = vgn->child;
|
||||
|
@ -934,7 +934,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name)
|
||||
}
|
||||
|
||||
vg->status = (RESIZEABLE_VG | LVM_READ | LVM_WRITE);
|
||||
if (!(vg->system_id = dm_pool_alloc(vg->vgmem, NAME_LEN)))
|
||||
if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
|
||||
goto_bad;
|
||||
|
||||
*vg->system_id = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user