diff options
author | Huang, Tao <huangtao@rock-chips.com> | 2015-12-01 09:14:17 +0800 |
---|---|---|
committer | Huang, Tao <huangtao@rock-chips.com> | 2015-12-01 09:14:17 +0800 |
commit | 87fb89c353234910f500934b5f83577d3df88810 (patch) | |
tree | f35b51c463e99bfa02ca70a81b680463e79b073a /block/partitions | |
parent | 8f09cde6a2612a8f07b033a18f0579169e8a9c95 (diff) | |
parent | 31ade3b83e1821da5fbb2f11b5b3d4ab2ec39db8 (diff) |
Merge tag 'v4.4-rc3'
Linux 4.4-rc3
Diffstat (limited to 'block/partitions')
-rw-r--r-- | block/partitions/mac.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/block/partitions/mac.c b/block/partitions/mac.c index c2c48ec64b27..621317ac4d59 100644 --- a/block/partitions/mac.c +++ b/block/partitions/mac.c @@ -32,7 +32,7 @@ int mac_partition(struct parsed_partitions *state) Sector sect; unsigned char *data; int slot, blocks_in_map; - unsigned secsize; + unsigned secsize, datasize, partoffset; #ifdef CONFIG_PPC_PMAC int found_root = 0; int found_root_goodness = 0; @@ -50,10 +50,14 @@ int mac_partition(struct parsed_partitions *state) } secsize = be16_to_cpu(md->block_size); put_dev_sector(sect); - data = read_part_sector(state, secsize/512, §); + datasize = round_down(secsize, 512); + data = read_part_sector(state, datasize / 512, §); if (!data) return -1; - part = (struct mac_partition *) (data + secsize%512); + partoffset = secsize % 512; + if (partoffset + sizeof(*part) > datasize) + return -1; + part = (struct mac_partition *) (data + partoffset); if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) { put_dev_sector(sect); return 0; /* not a MacOS disk */ |