]> err.no Git - util-linux/commitdiff
libblkid: prevent overflow in BeFS
authorJeroen Oortwijn <oortwijn@gmail.com>
Tue, 9 Mar 2010 22:15:30 +0000 (23:15 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 11 Mar 2010 13:34:00 +0000 (14:34 +0100)
Prevent overflow by casting values to blkid_loff_t before applying
block shift.

Signed-off-by: Jeroen Oortwijn <oortwijn@gmail.com>
shlibs/blkid/src/superblocks/befs.c

index b341402ada265d9df42fdc6153ee502d13370894..c238bae3ce90cbaf693a545bd78c464b0e068d69 100644 (file)
@@ -123,13 +123,13 @@ static int probe_befs(blkid_probe pr, const struct blkid_idmag *mag)
                return -1;
 
        bi = (struct befs_inode *) blkid_probe_get_buffer(pr,
-                       (FS32_TO_CPU(bs->root_dir.allocation_group, fs_le)
-                               << FS32_TO_CPU(bs->ag_shift, fs_le)
-                               << FS32_TO_CPU(bs->block_shift, fs_le))
-                       + (FS16_TO_CPU(bs->root_dir.start, fs_le)
-                               << FS32_TO_CPU(bs->block_shift, fs_le)),
-                       FS16_TO_CPU(bs->root_dir.len, fs_le)
-                               << FS32_TO_CPU(bs->block_shift, fs_le));
+               ((blkid_loff_t)FS32_TO_CPU(bs->root_dir.allocation_group, fs_le)
+                       << FS32_TO_CPU(bs->ag_shift, fs_le)
+                       << FS32_TO_CPU(bs->block_shift, fs_le))
+               + ((blkid_loff_t)FS16_TO_CPU(bs->root_dir.start, fs_le)
+                       << FS32_TO_CPU(bs->block_shift, fs_le)),
+               (blkid_loff_t)FS16_TO_CPU(bs->root_dir.len, fs_le)
+                       << FS32_TO_CPU(bs->block_shift, fs_le));
        if (!bi)
                return -1;