From: Theodore Ts'o Date: Thu, 9 Jan 2014 19:56:54 +0000 (-0500) Subject: libblkid: clean up some integer promotion / signed issues X-Git-Tag: v1.42.10~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1da14b5b0496621046179e5644cc924ce01dae1;p=thirdparty%2Fe2fsprogs.git libblkid: clean up some integer promotion / signed issues Addresses-Coverity-Id: #1049165 Addresses-Coverity-Id: #1049164 Addresses-Coverity-Id: #1049163 Addresses-Coverity-Id: #1049162 Addresses-Coverity-Id: #709508 Addresses-Coverity-Id: #709507 --- diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index dd3604e9d..b63a509ee 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -243,7 +243,7 @@ static int check_for_modules(const char *fs_name) return (0); } -static int linux_version_code() +static int linux_version_code(void) { #ifdef __linux__ struct utsname ut; @@ -585,7 +585,7 @@ static int probe_fat(struct blkid_probe *probe, __u64 next_off, fat_entry_off; int count; - next_sect_off = (next - 2) * vs->vs_cluster_size; + next_sect_off = (__u64) (next - 2) * vs->vs_cluster_size; next_off = (start_data_sect + next_sect_off) * sector_size; @@ -601,7 +601,9 @@ static int probe_fat(struct blkid_probe *probe, break; /* get FAT entry */ - fat_entry_off = (reserved * sector_size) + + fat_entry_off = + ((unsigned int) reserved * + (unsigned int) sector_size) + (next * sizeof(__u32)); buf = get_buffer(probe, fat_entry_off, buf_size); if (buf == NULL) @@ -1003,7 +1005,8 @@ static int probe_udf(struct blkid_probe *probe, (block sizes larger than 2K will be null padded) */ for (bs = 1; bs < 16; bs++) { isosb = (struct iso_volume_descriptor *) - get_buffer(probe, bs*2048+32768, sizeof(*isosb)); + get_buffer(probe, (blkid_loff_t) bs*2048+32768, + sizeof(*isosb)); if (!isosb) return 1; if (isosb->vd_id[0]) @@ -1247,7 +1250,7 @@ static int probe_hfsplus(struct blkid_probe *probe, memcpy(extents, hfsplus->cat_file.extents, sizeof(extents)); cat_block = blkid_be32(extents[0].start_block); - buf = get_buffer(probe, off + (cat_block * blocksize), 0x2000); + buf = get_buffer(probe, off + ((__u64) cat_block * blocksize), 0x2000); if (!buf) return 0; @@ -1278,7 +1281,7 @@ static int probe_hfsplus(struct blkid_probe *probe, if (ext == HFSPLUS_EXTENT_COUNT) return 0; - leaf_off = (ext_block_start + leaf_block) * blocksize; + leaf_off = (__u64) (ext_block_start + leaf_block) * blocksize; buf = get_buffer(probe, off + leaf_off, leaf_node_size); if (!buf) @@ -1580,7 +1583,7 @@ try_again: continue; idx = id->bim_kboff + (id->bim_sboff >> 10); - buf = get_buffer(&probe, idx << 10, 1024); + buf = get_buffer(&probe, (__u64) idx << 10, 1024); if (!buf) continue;