From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] part_dos: fix crash with big sector size
Date: Fri, 3 Jun 2011 23:37:43 +0400 [thread overview]
Message-ID: <201106032337.43523.sshtylyov@ru.mvista.com> (raw)
Apple iPod nanos have sector sizes of 2 or 4 KiB, which crashes U-Boot when it
tries to read the MBR into 512-byte buffer situated on stack. Instead use the
variable length arrays to be safe with any large sector size.
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
---
The same change is probably needed for disk/part_amiga.c but I'm not really
sure if Amiga supports USB... :-)
disk/part_dos.c | 6 +++---
disk/part_dos.h | 7 -------
2 files changed, 3 insertions(+), 10 deletions(-)
Index: u-boot/disk/part_dos.c
===================================================================
--- u-boot.orig/disk/part_dos.c
+++ u-boot/disk/part_dos.c
@@ -87,7 +87,7 @@ static int test_block_type(unsigned char
int test_part_dos (block_dev_desc_t *dev_desc)
{
- unsigned char buffer[DEFAULT_SECTOR_SIZE];
+ unsigned char buffer[dev_desc->blksz];
if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) ||
(buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
@@ -102,7 +102,7 @@ int test_part_dos (block_dev_desc_t *dev
static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_sector, int relative,
int part_num)
{
- unsigned char buffer[DEFAULT_SECTOR_SIZE];
+ unsigned char buffer[dev_desc->blksz];
dos_partition_t *pt;
int i;
@@ -166,7 +166,7 @@ static int get_partition_info_extended (
int relative, int part_num,
int which_part, disk_partition_t *info)
{
- unsigned char buffer[DEFAULT_SECTOR_SIZE];
+ unsigned char buffer[dev_desc->blksz];
dos_partition_t *pt;
int i;
Index: u-boot/disk/part_dos.h
===================================================================
--- u-boot.orig/disk/part_dos.h
+++ u-boot/disk/part_dos.h
@@ -25,13 +25,6 @@
#define _DISK_PART_DOS_H
-#ifdef CONFIG_ISO_PARTITION
-/* Make the buffers bigger if ISO partition support is enabled -- CD-ROMS
- have 2048 byte blocks */
-#define DEFAULT_SECTOR_SIZE 2048
-#else
-#define DEFAULT_SECTOR_SIZE 512
-#endif
#define DOS_PART_TBL_OFFSET 0x1be
#define DOS_PART_MAGIC_OFFSET 0x1fe
#define DOS_PBR_FSTYPE_OFFSET 0x36
next reply other threads:[~2011-06-03 19:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-03 19:37 Sergei Shtylyov [this message]
2011-07-04 17:06 ` [U-Boot] [PATCH] part_dos: fix crash with big sector size Sergei Shtylyov
2011-07-26 18:57 ` Sergei Shtylyov
2011-07-27 21:41 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201106032337.43523.sshtylyov@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox