Blame SOURCES/parted-3.1-libparted-Fix-endian-error-with-FirstUsableLBA.patch

fc4a62
From 1190dc5b214ce6ba4cbeadbdd599ab3ebb2cbb13 Mon Sep 17 00:00:00 2001
fc4a62
From: "Richard W.M. Jones" <rjones@redhat.com>
fc4a62
Date: Fri, 8 Jun 2012 14:42:45 -0700
fc4a62
Subject: [PATCH] libparted: Fix endian error with FirstUsableLBA (#829960)
fc4a62
fc4a62
On big-endial systems (eg. ppc64) this would cause parted to
fc4a62
crash.
fc4a62
fc4a62
* NEWS: add new bugfix
fc4a62
* libparted/labels/gpt.c (gpt_get_max_supported_partition_count):
fc4a62
  fix endian issues with pth->FirstUsableLBA
fc4a62
---
fc4a62
 NEWS                   |    3 ++-
fc4a62
 libparted/labels/gpt.c |    4 ++--
fc4a62
 2 files changed, 4 insertions(+), 3 deletions(-)
fc4a62
fc4a62
diff --git a/NEWS b/NEWS
fc4a62
index b0a0657..596ab37 100644
fc4a62
--- a/NEWS
fc4a62
+++ b/NEWS
fc4a62
@@ -1,9 +1,10 @@
fc4a62
 GNU parted NEWS                                    -*- outline -*-
fc4a62
 
fc4a62
-* Noteworthy changes in release 3.1-2 (2012-03-21) [Fedora]
fc4a62
+* Noteworthy changes in release 3.1-4 (2012-06-08) [Fedora]
fc4a62
 
fc4a62
 ** Bug Fixes
fc4a62
 
fc4a62
+  libparted: Don't crash on big-endian systems when using GPT
fc4a62
   libparted: Treat disks without a PMBR as msdos labeled disks
fc4a62
   even if they have GPT partition tables.
fc4a62
 
fc4a62
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
fc4a62
index ab2145e..6ca33c8 100644
fc4a62
--- a/libparted/labels/gpt.c
fc4a62
+++ b/libparted/labels/gpt.c
fc4a62
@@ -1787,12 +1787,12 @@ gpt_get_max_supported_partition_count (const PedDisk *disk, int *max_n)
fc4a62
 
fc4a62
   if (!_header_is_valid (disk, pth, 1))
fc4a62
     {
fc4a62
-      pth->FirstUsableLBA = 34;
fc4a62
+      pth->FirstUsableLBA = PED_CPU_TO_LE64 (34);
fc4a62
       pth->SizeOfPartitionEntry
fc4a62
         = PED_CPU_TO_LE32 (sizeof (GuidPartitionEntry_t));
fc4a62
     }
fc4a62
 
fc4a62
-  *max_n = (disk->dev->sector_size * (pth->FirstUsableLBA - 2)
fc4a62
+  *max_n = (disk->dev->sector_size * (PED_LE64_TO_CPU (pth->FirstUsableLBA)-2)
fc4a62
             / PED_LE32_TO_CPU (pth->SizeOfPartitionEntry));
fc4a62
   pth_free (pth);
fc4a62
   return true;
fc4a62
-- 
fc4a62
1.7.7.6
fc4a62