1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvmcache: check for too long pvid

This commit is contained in:
Zdenek Kabelac 2015-08-18 11:28:02 +02:00
parent 8e229cb7ea
commit 70db1d523d
2 changed files with 11 additions and 4 deletions

View File

@ -1178,7 +1178,12 @@ static int _lvmcache_update_pvid(struct lvmcache_info *info, const char *pvid)
return 1;
if (*info->dev->pvid)
dm_hash_remove(_pvid_hash, info->dev->pvid);
strncpy(info->dev->pvid, pvid, sizeof(info->dev->pvid));
if (!dm_strncpy(info->dev->pvid, pvid, sizeof(info->dev->pvid))){
log_error("_lvmcache_update: too long pvid: %s.", pvid);
return 0;
}
if (!dm_hash_insert(_pvid_hash, pvid, info)) {
log_error("_lvmcache_update: pvid insertion failed: %s", pvid);
return 0;

View File

@ -94,9 +94,11 @@ static int _text_write(struct label *label, void *buf)
* PV header base
*/
/* FIXME Move to where label is created */
strncpy(label->type, LVM2_LABEL, sizeof(label->type));
strncpy((char *)lh->type, label->type, sizeof(label->type));
if (!dm_strncpy(label->type, LVM2_LABEL, sizeof(label->type)) ||
!dm_strncpy((char *)lh->type, label->type, sizeof(label->type))) {
log_error(INTERNAL_ERROR "LVM2 label %s does not fit.", LVM2_LABEL);
return 0;
}
pvhdr = (struct pv_header *) ((char *) buf + xlate32(lh->offset_xl));
info = (struct lvmcache_info *) label->info;