diff options
author | Sergei Shtylyov | 2011-06-03 04:37:43 -0500 |
---|---|---|
committer | Wolfgang Denk | 2011-07-27 16:41:33 -0500 |
commit | 54193c5d8133f4f35267f412e5c1bbcbc6ac041c (patch) | |
tree | ffbad593301b722229711c4e7589de8ae8fc227b /disk/part_dos.c | |
parent | 4204298db0c5fcf14de852c9b2c6ac3324b106b1 (diff) | |
download | u-boot-54193c5d8133f4f35267f412e5c1bbcbc6ac041c.tar.gz u-boot-54193c5d8133f4f35267f412e5c1bbcbc6ac041c.tar.xz u-boot-54193c5d8133f4f35267f412e5c1bbcbc6ac041c.zip |
part_dos: fix crash with big sector size
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>
Diffstat (limited to 'disk/part_dos.c')
-rw-r--r-- | disk/part_dos.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/disk/part_dos.c b/disk/part_dos.c index 2de1bb83b7..b5bcb3735c 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c | |||
@@ -87,7 +87,7 @@ static int test_block_type(unsigned char *buffer) | |||
87 | 87 | ||
88 | int test_part_dos (block_dev_desc_t *dev_desc) | 88 | int test_part_dos (block_dev_desc_t *dev_desc) |
89 | { | 89 | { |
90 | unsigned char buffer[DEFAULT_SECTOR_SIZE]; | 90 | unsigned char buffer[dev_desc->blksz]; |
91 | 91 | ||
92 | if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) || | 92 | if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) || |
93 | (buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) || | 93 | (buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) || |
@@ -102,7 +102,7 @@ int test_part_dos (block_dev_desc_t *dev_desc) | |||
102 | static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_sector, int relative, | 102 | static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_sector, int relative, |
103 | int part_num) | 103 | int part_num) |
104 | { | 104 | { |
105 | unsigned char buffer[DEFAULT_SECTOR_SIZE]; | 105 | unsigned char buffer[dev_desc->blksz]; |
106 | dos_partition_t *pt; | 106 | dos_partition_t *pt; |
107 | int i; | 107 | int i; |
108 | 108 | ||
@@ -166,7 +166,7 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part | |||
166 | int relative, int part_num, | 166 | int relative, int part_num, |
167 | int which_part, disk_partition_t *info) | 167 | int which_part, disk_partition_t *info) |
168 | { | 168 | { |
169 | unsigned char buffer[DEFAULT_SECTOR_SIZE]; | 169 | unsigned char buffer[dev_desc->blksz]; |
170 | dos_partition_t *pt; | 170 | dos_partition_t *pt; |
171 | int i; | 171 | int i; |
172 | 172 | ||