Subject: Re: [PATCH SLOF] disk-label: add support for booting from GPT FAT partition

From: Thomas Huth <[email-masked]>
Date: Fri, 19 Jun 2015 18:35:32 +0200

On Thu, 18 Jun 2015 11:54:13 +0530
Nikunj A Dadhania <[email-masked]> wrote:

> Thomas Huth <[email-masked]> writes:
> 
> > On Thu, 11 Jun 2015 15:48:49 +0530
> > Nikunj A Dadhania <[email-masked]> wrote:
> >
> >> +   block-size * to seek-pos
> >> +   block gpt>part-entry-size l@-le to gpt-part-size
> >> +   block gpt>num-part-entry l@-le dup 0= IF FALSE EXIT THEN
> >> +   1+ 1 ?DO
> >> +      seek-pos 0 seek drop
> >> +      block gpt-part-size read drop
> >
> > Can you be sure that gpt-part-size is only smaller than 4096 bytes
> > here? 
> 
> So the size is usually 128, so this should be fine.
> 
> https://en.wikipedia.org/wiki/GUID_Partition_Table
> 
> Section: GPT header format
> 
> "84 (0x54)	4 bytes	Size of a single partition entry (usually 128)"

Ok, so it should be fine when you have a valid GPT ... however, one
thing I learnt during my past years: Never ever blindly trust data that
you get from an external medium ... it could have been corrupted by
accident or on purpose. So if you want to make your code more robust,
maybe better check gpt>part-entry-size for being in the range of d# 128
to d# 4096 or you might have to debug very strange crashes one day...

 Thomas