From 5f05971a84a6accb43d1032eb2b5de8222a197d4 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 23 May 2002 11:37:51 +0000 Subject: [PATCH] Fix LVM1 backwards compatibility issue when LV with a low LV number is deleted. --- lib/format1/disk-rep.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c index 0ddea822d..d0005b6fd 100644 --- a/lib/format1/disk-rep.c +++ b/lib/format1/disk-rep.c @@ -500,7 +500,7 @@ static int _write_lvd(struct device *dev, ulong pos, struct lv_disk *disk) static int _write_lvs(struct disk_list *data) { struct list *lvh; - ulong pos; + ulong pos, offset; pos = data->pvd.lv_on_disk.base; @@ -513,10 +513,15 @@ static int _write_lvs(struct disk_list *data) list_iterate(lvh, &data->lvds) { struct lvd_list *ll = list_item(lvh, struct lvd_list); - if (!_write_lvd(data->dev, pos, &ll->lvd)) - fail; + offset = sizeof(struct lv_disk) * ll->lvd.lv_number; + if (offset + sizeof(struct lv_disk) > + data->pvd.lv_on_disk.size) { + log_error("lv_number %d too large", ll->lvd.lv_number); + return 0; + } - pos += sizeof(struct lv_disk); + if (!_write_lvd(data->dev, pos + offset, &ll->lvd)) + fail; } return 1; -- 2.43.5