From 96261585f19894de8514a7ed81b3fede570f5d86 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 10 Jan 2019 09:21:43 +0100 Subject: [PATCH] Bug fix: Appended GPT partitions were not covered by the protective MBR partition --- libisofs/system_area.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libisofs/system_area.c b/libisofs/system_area.c index 0c9e293..9ef222a 100644 --- a/libisofs/system_area.c +++ b/libisofs/system_area.c @@ -2079,6 +2079,21 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf) } } + /* Check for protective MBR in mbr_req and adjust to GPT size */ + if (t->gpt_req_count > 0 && sa_type == 0 && t->mbr_req_count == 1) { + if (t->mbr_req[0]->type_byte == 0xee && buf[450] == 0xee && + t->mbr_req[0]->desired_slot <= 1) { + part_type = 0xee; + risk_of_ee = 1; + ret = write_mbr_partition_entry(1, part_type, + (uint64_t) 1, ((uint64_t) gpt_blocks) * 4 - 1, + t->partition_secs_per_head, t->partition_heads_per_cyl, + buf, 2); + if (ret < 0) + return ret; + } + } + if (t->opts->partition_offset > 0 && sa_type == 0 && t->mbr_req_count == 0) { /* Adjust partition table to partition offset.