bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Minimum size of GPT partition table header


From: rahul dev
Subject: Minimum size of GPT partition table header
Date: Thu, 20 Sep 2012 12:14:28 +0800 (SGT)

Guys,

   There seems to be a bug in function _header_is_valid() in file gpt.c.

static int
_header_is_valid (PedDisk const *disk, GuidPartitionTableHeader_t *gpt,
                  PedSector my_lba)
{
  uint32_t crc, origcrc;
  PedDevice const *dev = disk->dev;

  if (PED_LE64_TO_CPU (gpt->Signature) != GPT_HEADER_SIGNATURE)
    return 0;
  /*
   * "While the GUID Partition Table Header's size may increase
   * in the future it cannot span more than one block on the
   * device."  EFI Specification, version 1.10, 11.2.2.1
   */
  if (PED_LE32_TO_CPU (gpt->HeaderSize) < pth_get_size_static (dev)
      || PED_LE32_TO_CPU (gpt->HeaderSize) > dev->sector_size)
    return 0;


The check gpt->HeaderSize < pth_get_size_static seems to be incorrect.
I think minimum size of gpt header is 92 bytes. So, correct check should be
gtp->HeaderSize < 92.

As mentioned in the EFI spec that the header size may increase in future, 
pth_get_size_static() will also return the increased size. In that case, if we 
are running parted on a disk partitioned by old versions, the above check would 
fail. For older versions, gpt->HeaderSize is 92, whereas pth_get_size_static() 
will be > 92 for newer versions (where gpt hdr size has been increased).

Any thoughts ?

 








reply via email to

[Prev in Thread] Current Thread [Next in Thread]