bug-parted
[Top][All Lists]
Advanced

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

Bug in parted-1.6.6


From: Takahiro Sajima
Subject: Bug in parted-1.6.6
Date: Fri, 03 Oct 2003 22:46:44 +0900 (JST)

Hi,

There is a bug in parted-1.6.6, file libparted/disk_gpt.c, function
gpt_read().

About 2/3 down, there is a statement calculating ptes_size:

ptes_size = sizeof (GuidPartitionEntry_t) * gpt_disk_data->entry_count;
ptes = (GuidPartitionEntry_t*) ped_malloc (ptes_size);
if (!ped_device_read (disk->dev, ptes,
                      PED_LE64_TO_CPU(gpt.PartitionEntryLBA),
                      ptes_size / 512))
        goto error_free_ptes;


Note that sizeof (GuidPartitionEntry_t) is 128.

If the value of gpt_disk_data->entry_count is not a multiple of 4,
some of the partition entries will be missed.  This is because partition
entries are read from the disk in terms of 512 byte blocks.

For example, if there are 9 partition entries, only the first 8 of
them will be read.

One possible fix is make sure that ptes_size is round UP to the next
block size (512 byte) boundary:

ptes_size = sizeof (GuidPartitionEntry_t) * 
        (gpt_disk_data->entry_count + (4 - (gpt_disk_data->entry_count & 0x3)));

I'm sure that there are other (better) ways to fix this.

Thanks,
/tjs





reply via email to

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