From a0719328ea4d23dd0850efc91a3865b1ea3d9def Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 18 Apr 2015 14:07:16 +0200 Subject: [PATCH] Bug fix: A zero sized GPT partition was marked after the last appended GPT partition. --- libisofs/system_area.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libisofs/system_area.c b/libisofs/system_area.c index 38bd1e5..886c2be 100644 --- a/libisofs/system_area.c +++ b/libisofs/system_area.c @@ -1567,6 +1567,7 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf) if (t->gpt_req_count == 0) return 2; + backup_end_lba = ((uint64_t) t->gpt_backup_end - t->gpt_backup_size) * 4; /* Sort and fill gaps */ qsort(t->gpt_req, t->gpt_req_count, @@ -1580,6 +1581,8 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf) goal = t->gpt_req[i]->start_block; } else { goal = ((uint64_t) img_blocks) * 4; + if (goal > backup_end_lba) + goal = backup_end_lba; } if (i == 0) { if (goal <= 16 * 4) @@ -1627,8 +1630,6 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf) req = t->gpt_req[i]; start_lba = req->start_block; end_lba = req->start_block + req->block_count; - backup_end_lba = ((uint64_t) t->gpt_backup_end - t->gpt_backup_size) * - 4; if (req->start_block == t->opts->partition_offset * ((uint64_t) 4) && req->block_count == ((uint64_t) 4) * 0xffffffff) end_lba = t->vol_space_size * 4;