gpt: properly detect and repair invalid tables
GPT_BOTH_VALID is 4 bits so simple a boolean check is not sufficient. This broken condition allowed gptprio to trust bogus disk locations in headers that were marked invalid causing arbitrary disk corruption.
This commit is contained in:
parent
4d91c78833
commit
6078f83638
2 changed files with 2 additions and 2 deletions
|
@ -91,7 +91,7 @@ grub_find_next (const char *disk_name,
|
||||||
if (!gpt)
|
if (!gpt)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (!(gpt->status & GRUB_GPT_BOTH_VALID))
|
if ((gpt->status & GRUB_GPT_BOTH_VALID) != GRUB_GPT_BOTH_VALID)
|
||||||
if (grub_gpt_repair (dev->disk, gpt))
|
if (grub_gpt_repair (dev->disk, gpt))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
|
|
@ -593,7 +593,7 @@ grub_gpt_write (grub_disk_t disk, grub_gpt_t gpt)
|
||||||
{
|
{
|
||||||
/* TODO: update/repair protective MBRs too. */
|
/* TODO: update/repair protective MBRs too. */
|
||||||
|
|
||||||
if (!(gpt->status & GRUB_GPT_BOTH_VALID))
|
if ((gpt->status & GRUB_GPT_BOTH_VALID) != GRUB_GPT_BOTH_VALID)
|
||||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "Invalid GPT data");
|
return grub_error (GRUB_ERR_BAD_PART_TABLE, "Invalid GPT data");
|
||||||
|
|
||||||
grub_dprintf ("gpt", "writing primary GPT to %s\n", disk->name);
|
grub_dprintf ("gpt", "writing primary GPT to %s\n", disk->name);
|
||||||
|
|
Loading…
Reference in a new issue