diff options
author | Jens Arnold <amiconn@rockbox.org> | 2008-05-15 22:23:14 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2008-05-15 22:23:14 +0000 |
commit | 3cec5e2b6a1039bb065d5f7bc8e9bc3dafe3f904 (patch) | |
tree | b85729e9c7ce34949118b92bbc243b50890656cc /firmware/common/disk.c | |
parent | 83e6be56493de6f66d6c6b6d2e3f06b01bc8730d (diff) |
Check for a supported partition type before trying to mount a partition. This will reduce the risk of irregular mounts, e.g. due to stray FAT boot sectors when probing the logical sector size on iPod Video.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17530 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/disk.c')
-rw-r--r-- | firmware/common/disk.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/firmware/common/disk.c b/firmware/common/disk.c index 27b79755e7..8135c60bc5 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -46,12 +46,23 @@ ((long)array[pos] | ((long)array[pos+1] << 8 ) | \ ((long)array[pos+2] << 16 ) | ((long)array[pos+3] << 24 )) +static const unsigned char fat_partition_types[] = { + 0x0b, 0x1b, /* FAT32 + hidden variant */ + 0x0c, 0x1c, /* FAT32 (LBA) + hidden variant */ +#ifdef HAVE_FAT16SUPPORT + 0x04, 0x14, /* FAT16 <= 32MB + hidden variant */ + 0x06, 0x16, /* FAT16 > 32MB + hidden variant */ + 0x0e, 0x1e, /* FAT16 (LBA) + hidden variant */ +#endif +}; + static struct partinfo part[8]; /* space for 4 partitions on 2 drives */ static int vol_drive[NUM_VOLUMES]; /* mounted to which drive (-1 if none) */ #ifdef MAX_LOG_SECTOR_SIZE int disk_sector_multiplier = 1; #endif + struct partinfo* disk_init(IF_MV_NONVOID(int drive)) { int i; @@ -194,9 +205,13 @@ int disk_mount(int drive) #endif for (; volume != -1 && i<4; i++) { + if (memchr(fat_partition_types, pinfo[i].type, + sizeof(fat_partition_types)) == NULL) + continue; /* not an accepted partition type */ + #ifdef MAX_LOG_SECTOR_SIZE int j; - + for (j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1) { if (!fat_mount(IF_MV2(volume,) IF_MV2(drive,) pinfo[i].start * j)) |