From 7e256156f4a8650f0e5c5aaea9cf93d9bf3e1294 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 16 Mar 2011 14:06:23 +0100 Subject: [PATCH] libblkid: use blkid_probe_get_buffer() more carefully Signed-off-by: Karel Zak --- shlibs/blkid/src/superblocks/hfs.c | 6 ++++-- shlibs/blkid/src/superblocks/udf.c | 8 +++++--- shlibs/blkid/src/superblocks/vfat.c | 8 +++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/shlibs/blkid/src/superblocks/hfs.c b/shlibs/blkid/src/superblocks/hfs.c index 033a65dea2..aa9da0ce66 100644 --- a/shlibs/blkid/src/superblocks/hfs.c +++ b/shlibs/blkid/src/superblocks/hfs.c @@ -229,7 +229,7 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag) cat_block = be32_to_cpu(extents[0].start_block); buf = blkid_probe_get_buffer(pr, - off + (cat_block * blocksize), 0x2000); + off + ((blkid_loff_t) cat_block * blocksize), 0x2000); if (!buf) return 0; @@ -262,7 +262,9 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag) leaf_off = (ext_block_start + leaf_block) * blocksize; - buf = blkid_probe_get_buffer(pr, off + leaf_off, leaf_node_size); + buf = blkid_probe_get_buffer(pr, + (blkid_loff_t) off + leaf_off, + leaf_node_size); if (!buf) return 0; diff --git a/shlibs/blkid/src/superblocks/udf.c b/shlibs/blkid/src/superblocks/udf.c index 78ddda6844..766d6980fa 100644 --- a/shlibs/blkid/src/superblocks/udf.c +++ b/shlibs/blkid/src/superblocks/udf.c @@ -55,7 +55,7 @@ struct volume_structure_descriptor { uint8_t version; } __attribute__((packed)); -#define UDF_VSD_OFFSET 0x8000 +#define UDF_VSD_OFFSET 0x8000LL static int probe_udf(blkid_probe pr, const struct blkid_idmag *mag) { @@ -86,7 +86,7 @@ nsr: for (b = 0; b < 64; b++) { vsd = (struct volume_structure_descriptor *) blkid_probe_get_buffer(pr, - UDF_VSD_OFFSET + (b * bs), + UDF_VSD_OFFSET + ((blkid_loff_t) b * bs), sizeof(*vsd)); if (!vsd) return -1; @@ -117,7 +117,9 @@ anchor: /* pick the primary descriptor from the list */ for (b = 0; b < count; b++) { vd = (struct volume_descriptor *) - blkid_probe_get_buffer(pr, (loc + b) * bs, sizeof(*vd)); + blkid_probe_get_buffer(pr, + (blkid_loff_t) (loc + b) * bs, + sizeof(*vd)); if (!vd) return -1; diff --git a/shlibs/blkid/src/superblocks/vfat.c b/shlibs/blkid/src/superblocks/vfat.c index 60191b99e3..29c4da2a18 100644 --- a/shlibs/blkid/src/superblocks/vfat.c +++ b/shlibs/blkid/src/superblocks/vfat.c @@ -132,7 +132,8 @@ static unsigned char *search_fat_label(blkid_probe pr, dir = (struct vfat_dir_entry *) blkid_probe_get_buffer(pr, offset, - entries * sizeof(struct vfat_dir_entry)); + (blkid_loff_t) entries * + sizeof(struct vfat_dir_entry)); if (!dir) return NULL; } @@ -146,7 +147,8 @@ static unsigned char *search_fat_label(blkid_probe pr, if (!dir) ent = (struct vfat_dir_entry *) blkid_probe_get_buffer(pr, - offset + (i * sizeof(struct vfat_dir_entry)), + (blkid_loff_t) offset + (i * + sizeof(struct vfat_dir_entry)), sizeof(struct vfat_dir_entry)); else ent = &dir[i]; @@ -373,7 +375,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag) struct fat32_fsinfo *fsinfo; buf = blkid_probe_get_buffer(pr, - fsinfo_sect * sector_size, + (blkid_loff_t) fsinfo_sect * sector_size, sizeof(struct fat32_fsinfo)); if (buf == NULL) return -1; -- 2.47.3