gpt: refuse to write to sector 0
This commit is contained in:
parent
8278022a0b
commit
c68fcd3b1a
1 changed files with 7 additions and 0 deletions
|
@ -626,10 +626,17 @@ grub_gpt_write_table (grub_disk_t disk, grub_gpt_t gpt,
|
||||||
sizeof (*header));
|
sizeof (*header));
|
||||||
|
|
||||||
addr = grub_gpt_sector_to_addr (gpt, grub_le_to_cpu64 (header->header_lba));
|
addr = grub_gpt_sector_to_addr (gpt, grub_le_to_cpu64 (header->header_lba));
|
||||||
|
if (addr == 0)
|
||||||
|
return grub_error (GRUB_ERR_BUG,
|
||||||
|
"Refusing to write GPT header to address 0x0");
|
||||||
if (grub_disk_write (disk, addr, 0, sizeof (*header), header))
|
if (grub_disk_write (disk, addr, 0, sizeof (*header), header))
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
addr = grub_gpt_sector_to_addr (gpt, grub_le_to_cpu64 (header->partitions));
|
addr = grub_gpt_sector_to_addr (gpt, grub_le_to_cpu64 (header->partitions));
|
||||||
|
if (addr < 2)
|
||||||
|
return grub_error (GRUB_ERR_BUG,
|
||||||
|
"Refusing to write GPT entries to address 0x%llx",
|
||||||
|
(unsigned long long) addr);
|
||||||
if (grub_disk_write (disk, addr, 0, gpt->entries_size, gpt->entries))
|
if (grub_disk_write (disk, addr, 0, gpt->entries_size, gpt->entries))
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue