hfsplus: fix overflow in hfsplus_read_wrapper
authorChristoph Hellwig <hch@tuxera.com>
Wed, 16 Feb 2011 08:34:22 +0000 (09:34 +0100)
committerChristoph Hellwig <hch@lst.de>
Thu, 30 Jun 2011 11:40:59 +0000 (13:40 +0200)
For partitions larger than 2TB or at such an offset the hfs wrapper code
in hfsplus might overflow the range representable in a 32-bit
data type. Make sure we use a sector_t for the arithmetics leading to it.

I'm not sure this code can be readed at all as hfs itself never supported
such large volumes.

Signed-off-by: Christoph Hellwig <hch@tuxera.com>
fs/hfsplus/wrapper.c

index 4ac88ff79aa6671ef37b66fdbb96d7e6ff5609f7..4b86468125c155f4af29ed230bc84f60da10b3dc 100644 (file)
@@ -172,8 +172,9 @@ reread:
                if (!hfsplus_read_mdb(sbi->s_vhdr, &wd))
                        goto out_free_backup_vhdr;
                wd.ablk_size >>= HFSPLUS_SECTOR_SHIFT;
-               part_start += wd.ablk_start + wd.embed_start * wd.ablk_size;
-               part_size = wd.embed_count * wd.ablk_size;
+               part_start += (sector_t)wd.ablk_start +
+                              (sector_t)wd.embed_start * wd.ablk_size;
+               part_size = (sector_t)wd.embed_count * wd.ablk_size;
                goto reread;
        default:
                /*