[parted-devel] [PATCH 2/2] libparted: gpt: verify header is outside usable area

Jim Meyering jim at meyering.net
Tue Sep 11 17:17:32 UTC 2012


Davidlohr Bueso wrote:
> The first usable logical block can be used by a GUID partition
> entry, and therefore cannot be used by the header.
> ---
>  libparted/labels/gpt.c |    3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
> index 6dfaf3e..42e702d 100644
> --- a/libparted/labels/gpt.c
> +++ b/libparted/labels/gpt.c
> @@ -652,6 +652,9 @@ _header_is_valid (PedDisk const *disk, GuidPartitionTableHeader_t *gpt,
>    PedSector first_usable = PED_LE64_TO_CPU (gpt->FirstUsableLBA);
>    PedSector last_usable = PED_LE64_TO_CPU (gpt->LastUsableLBA);
>
> +  if (first_usable < my_lba && last_usable > my_lba)
> +    return 0;

Thank you for the patch.
However, starting about 18 months ago, with commit v2.3-100-g2afb821,
there is a stronger test in that function:

    PedSector first_usable = PED_LE64_TO_CPU (gpt->FirstUsableLBA);
    if (first_usable < 3)
      return 0;



More information about the parted-devel mailing list