bug-parted
[Top][All Lists]
Advanced

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

Re: assertion PED_LE64_TO_CPU (gpt->AlternateLBA) <= disk->dev->length f


From: Petr Uzel
Subject: Re: assertion PED_LE64_TO_CPU (gpt->AlternateLBA) <= disk->dev->length failed
Date: Wed, 5 Nov 2008 10:24:29 +0100
User-agent: Mutt/1.5.17 (2007-11-01)

On Tue, Aug 26, 2008 at 12:27:21PM -0600, Bjorn Helgaas wrote:
> > Yes, that is probably the root of the problem.
> > The assertion is Parted's way of warning you that your
> > disk/partition table is corrupted in a surprising/unusual way.
> > Can you suggest a better way to handle this sort of failure?
> 
> My preference would be:
> 
>   - Since there's a valid GPT at the beginning of the image, and only
>     the secondary copy is missing, warn that the secondary copy is
>     missing or corrupted and continue.

What about this fix? Just a proposal...

>From c44a42e6a15388bf87de873fbca07796c0139b69 Mon Sep 17 00:00:00 2001
From: Petr Uzel <address@hidden>
Date: Wed, 5 Nov 2008 10:17:07 +0100
Subject: [PATCH] print warning instead of crash on corrupted GPT

---
 libparted/labels/gpt.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 13d2e88..c20d729 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -824,8 +824,18 @@ gpt_read (PedDisk * disk)
                goto error;
 
        if (_read_header (disk->dev, &gpt, 1)) {
-               PED_ASSERT ((PedSector) PED_LE64_TO_CPU (gpt->AlternateLBA)
-                               <= disk->dev->length - 1, goto error_free_gpt);
+               if ((PedSector) PED_LE64_TO_CPU (gpt->AlternateLBA)
+                               > disk->dev->length - 1) {
+                       if (ped_exception_throw (
+                               PED_EXCEPTION_WARNING,
+                               PED_EXCEPTION_IGNORE_CANCEL,
+               _("The primary GPT table states that the backup GPT table is "
+                 "located at the position that is beyond the end of the disk. "
+                 "This means that the GPT structure is corrupted."))
+                                   == PED_EXCEPTION_CANCEL)
+                               goto error_free_gpt;
+               }
+
                if ((PedSector) PED_LE64_TO_CPU (gpt->AlternateLBA)
                                < disk->dev->length - 1) {
                        char* zeros = ped_malloc (pth_get_size (disk->dev));
-- 
1.6.0.2


-- 
Best regards / s pozdravem

Petr Uzel, Packages maintainer
---------------------------------------------------------------------
SUSE LINUX, s.r.o.                          e-mail: address@hidden
Lihovarská 1060/12                          tel: +420 284 028 964
190 00 Prague 9                             fax: +420 284 028 951
Czech Republic                              http://www.suse.cz




reply via email to

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