summaryrefslogtreecommitdiff
path: root/libparted/labels/gpt.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-06-08 13:19:25 +0100
committerJim Meyering <meyering@redhat.com>2012-06-09 18:55:08 +0200
commit4ac1c02b590668c93afdb48900e0858de58cda3a (patch)
tree743748f99d1fab420aeb39d0911948a8b198abcb /libparted/labels/gpt.c
parent7fd33a6d24da6a82b830552999b2332140f556d4 (diff)
downloadparted-4ac1c02b590668c93afdb48900e0858de58cda3a.tar.gz
gpt: fix endianness bug in gpt_get_max_supported_partition_count
* libparted/labels/gpt.c (gpt_get_max_supported_partition_count): Take endianness of pth->FirstUsableLBA into account (64-bit, little endian) when calculating the maximum number of partitions. * NEWS (Bug fixes): Mention it.
Diffstat (limited to 'libparted/labels/gpt.c')
-rw-r--r--libparted/labels/gpt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 91ad71a..6032e3f 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1785,12 +1785,12 @@ gpt_get_max_supported_partition_count (const PedDisk *disk, int *max_n)
if (!_header_is_valid (disk, pth, 1))
{
- pth->FirstUsableLBA = 34;
+ pth->FirstUsableLBA = PED_CPU_TO_LE64 (34);
pth->SizeOfPartitionEntry
= PED_CPU_TO_LE32 (sizeof (GuidPartitionEntry_t));
}
- *max_n = (disk->dev->sector_size * (pth->FirstUsableLBA - 2)
+ *max_n = (disk->dev->sector_size * (PED_LE64_TO_CPU (pth->FirstUsableLBA) - 2)
/ PED_LE32_TO_CPU (pth->SizeOfPartitionEntry));
pth_free (pth);
return true;