]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
part_dos: fix crash with big sector size
authorSergei Shtylyov <sshtylyov@ru.mvista.com>
Fri, 3 Jun 2011 09:37:43 +0000 (09:37 +0000)
committerWolfgang Denk <wd@denx.de>
Wed, 27 Jul 2011 21:41:33 +0000 (23:41 +0200)
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>
disk/part_dos.c
disk/part_dos.h

index 2de1bb83b7d8631cd43d2acb123d7cacb820efe0..b5bcb3735c0fb6148e3c09736694b0fbb833d653 100644 (file)
@@ -87,7 +87,7 @@ static int test_block_type(unsigned char *buffer)
 
 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_desc)
 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 (block_dev_desc_t *dev_desc, int ext_part
                                 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 195a32cb3887ca7ca3429e6a326e85f8aa7f0fec..de755425e0e476de6be3c4d8e1fa685cc0d5284f 100644 (file)
 #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