[parted-devel] [PATCH] [resend] Fixed improper data conversion in _parse_header()

Petr Uzel petr.uzel at suse.cz
Wed Nov 12 14:01:21 UTC 2008


On Tue, Nov 11, 2008 at 09:44:13AM -0500, Joel Granados wrote:
> Do you have a test case where the failure is made apparent?

I have a bugreport in Novell bugzilla that parted fails on disks of
certain sizes (e.g. 73.4GB) on big endian machines. Unfortunately the
bug is not public so I can not provide you a link :( .

Anyway, comparing two values, where one of them is in LE64 format
(last_usable_if_grown) and the other is in CPU format
(last_usable_min_default), looks like an obvious bug to me.


> Moreover, look at commit ecea0c9857813beae1c91b0afa39c17634b97a95.  Any reason why those other places don't have this change?

I do not see any other place that should be changed. Do you?


> 
> ----- "Petr Uzel" <petr.uzel at suse.cz> wrote:
> 
> > Hi,
> > I've already sent this patch, but there was no response, so I'm
> > resending it with modified subject. 
> > 
> > It fixes a bug in _parse_header() function that may cause parted to
> > fail on 73.4 GB disks.
> > 
> > The problem is that last_usable_if_grown and last_usable_min_default
> > should be both CPU format, but last_usable_if_grown is converted to
> > LE64.
> > 
> > ---
> >  libparted/labels/gpt.c |    5 ++---
> >  1 files changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
> > index 13d2e88..5ba4be9 100644
> > --- a/libparted/labels/gpt.c
> > +++ b/libparted/labels/gpt.c
> > @@ -675,11 +675,10 @@ _parse_header (PedDisk* disk,
> > GuidPartitionTableHeader_t* gpt,
> >     parted invocation.
> >  */
> >     
> > -	last_usable_if_grown 
> > -		= PED_CPU_TO_LE64 (disk->dev->length - 2 - 
> > +	last_usable_if_grown = disk->dev->length - 2 - 
> >  		((PedSector)(PED_LE32_TO_CPU(gpt->NumberOfPartitionEntries)) * 
> >  		(PedSector)(PED_LE32_TO_CPU(gpt->SizeOfPartitionEntry)) / 
> > -		disk->dev->sector_size));
> > +		disk->dev->sector_size);
> >  
> >  	last_usable_min_default = disk->dev->length - 2 - 
> >  		GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / disk->dev->sector_size;
> > -- 
> > 1.6.0.2
> > 
> > 
> > -- 
> > Best regards / s pozdravem
> > 
> > Petr Uzel, Packages maintainer
> > ---------------------------------------------------------------------
> > SUSE LINUX, s.r.o.                          e-mail: puzel at suse.cz
> > Lihovarská 1060/12                          tel: +420 284 028 964
> > 190 00 Prague 9                             fax: +420 284 028 951
> > Czech Republic                              http://www.suse.cz
> > 
> > _______________________________________________
> > parted-devel mailing list
> > parted-devel at lists.alioth.debian.org
> > http://lists.alioth.debian.org/mailman/listinfo/parted-devel
> 
> -- 
> Joel Andres Granados
> Red Hat / Brno Czech Republic

-- 
Best regards / s pozdravem

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



More information about the parted-devel mailing list