From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Sun, 18 Oct 2009 22:50:37 +0200 Subject: [U-Boot] [PATCH] part_dos: check status flags of partitions In-Reply-To: <20090928100400.GY9361@buzzloop.caiaq.de> References: <20090928100400.GY9361@buzzloop.caiaq.de> Message-ID: <20091018205037.ED9DA3F6CE@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Daniel Mack, In message <20090928100400.GY9361@buzzloop.caiaq.de> you wrote: > The current fatload code has a problem together with the way the DOS > partition parser is implemented. > > This hit me when I tried to load a file from a USB stick which had no > partition table but a FAT16 directly written to the first sector. > > With such an environment, get_partition_info_extended() still finds a > valid partition at the first sector since the 0x55aa magic is valid for > both the MBR and the FAT boot sector. > > As a result, part_offset in fs/fat/fat.c is then set to some ridiculous > value and the code searching for the directory entry gets lots in an > endless loop. > > The fix is quite simple though - we just need to check the status field > of the partitions more stricly. According to the specs, it may only > contain 0x00 and 0x80. If get_partition_info() fails for this case, the > fatload code falls back to the assumption that there is no partition > table and does the right thing then. > > Please consider applying the following patch. > > Daniel > > > From 381a85bf04adc228cc70e8fa7af899a6dbf07e42 Mon Sep 17 00:00:00 2001 > From: Daniel Mack > Date: Mon, 28 Sep 2009 11:40:38 +0200 > Subject: [PATCH] part_dos: check status flags of partitions > > Only read partitions which have 0x00 or 0x80 set in their status field. > All others are invalid. > > Signed-off-by: Daniel Mack > --- > disk/part_dos.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) Applied, thanks. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Digital computers are themselves more complex than most things people build: They have very large numbers of states. This makes conceiving, describing, and testing them hard. Software systems have orders-of- magnitude more states than computers do. - Fred Brooks, Jr.