Browse Source

Bug fix: The GUIDs of main GPT and backup GPT differed if more than one

System Area was written into the ISO image.
release-1.5.4.branch
Thomas Schmitt 7 years ago
parent
commit
a394f4dfd2
  1. 1
      libisofs/ecma119.c
  2. 2
      libisofs/ecma119.h
  3. 13
      libisofs/system_area.c

1
libisofs/ecma119.c

@ -1946,6 +1946,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
target->gpt_req[i] = NULL;
target->gpt_req_count = 0;
target->gpt_req_flags = 0;
target->gpt_disk_guid_set = 0;
target->gpt_part_start = 0;
target->gpt_backup_end = 0;
target->gpt_backup_size = 0;

2
libisofs/ecma119.h

@ -808,6 +808,8 @@ struct ecma119_image
/* Messages from gpt_tail_writer_compute_data_blocks() to
iso_write_system_area().
*/
uint8_t gpt_disk_guid[16];
int gpt_disk_guid_set;
/* Start of GPT entries in System Area, block size 512 */
uint32_t gpt_part_start;
/* The ISO block number after the backup GPT header , block size 2048 */

13
libisofs/system_area.c

@ -1385,11 +1385,9 @@ static void iso_write_gpt_entry(Ecma119Image *t, uint8_t *buf,
for (i = 0; i < 16; i++)
if (part_uuid[i])
break;
if (i < 16) {
memcpy(wpt, part_uuid, 16);
} else {
iso_random_uuid(t, (uint8_t *) wpt);
}
if (i == 16)
iso_random_uuid(t, part_uuid);
memcpy(wpt, part_uuid, 16);
wpt += 16;
iso_lsb_to_buf(&wpt, start_lba & 0xffffffff, 4, 0);
iso_lsb_to_buf(&wpt, (start_lba >> 32) & 0xffffffff, 4, 0);
@ -1450,7 +1448,10 @@ int iso_write_gpt_header_block(Ecma119Image *t, uint32_t img_blocks,
/* Disk GUID */
/* >>> Make adjustable */
iso_random_uuid(t, (uint8_t *) wpt);
if (!t->gpt_disk_guid_set)
iso_random_uuid(t, t->gpt_disk_guid);
t->gpt_disk_guid_set = 1;
memcpy(wpt, t->gpt_disk_guid, 16);
wpt += 16;
/* Partition entries start */

Loading…
Cancel
Save