diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2011-03-13 23:05:48 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2011-03-13 23:05:48 +0000 |
commit | 844b75f4d677b4ddb398798d1cb0fcc68d53bbb5 (patch) | |
tree | a67dd2a4edd8a0b1624ae3ff119ce241e0e64c07 /lib/format1/import-export.c | |
parent | e1cb521dd9f85bb1d4465f12edfb16bb6106e19c (diff) | |
download | lvm2-844b75f4d677b4ddb398798d1cb0fcc68d53bbb5.tar.gz lvm2-844b75f4d677b4ddb398798d1cb0fcc68d53bbb5.tar.xz lvm2-844b75f4d677b4ddb398798d1cb0fcc68d53bbb5.zip |
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.
Diffstat (limited to 'lib/format1/import-export.c')
-rw-r--r-- | lib/format1/import-export.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c index d0b1b31f..c065016b 100644 --- a/lib/format1/import-export.c +++ b/lib/format1/import-export.c @@ -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'; |