aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2022-08-11 22:03:08 -0400
committerTheodore Ts'o <tytso@mit.edu>2022-08-11 22:03:08 -0400
commit6b3edcd191c20b3fb108f0d7564aaa930035d0ab (patch)
tree63bf445a0d4e918da783d38f30359490edc3c936
parentec30a439282fd4703d302f1f98fbad3ce9f99db2 (diff)
downloade2fsprogs-6b3edcd191c20b3fb108f0d7564aaa930035d0ab.tar.gz
Fix Coverity unintentional integer overflow warnings
Neither of these two warnings can actually happen (other limits will be hit first), but widening the integer to a 64-bit unsigned integer is an cheap and effective way to silence the Coverity warnings. Addresses-Coverity-Bug: 1500760 Addresses-Coverity-Bug: 1507886 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--misc/e2image.c2
-rw-r--r--resize/main.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/misc/e2image.c b/misc/e2image.c
index 0053b5156..207c30374 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -943,7 +943,7 @@ static errcode_t initialize_qcow2_image(int fd, ext2_filsys fs,
header->refcount_table_clusters =
ext2fs_cpu_to_be32(image->refcount.refcount_table_clusters);
offset += image->cluster_size;
- offset += image->refcount.refcount_table_clusters <<
+ offset += (blk64_t) image->refcount.refcount_table_clusters <<
image->cluster_bits;
/* Make space for L2 tables */
diff --git a/resize/main.c b/resize/main.c
index a1a1c79a8..b745c58c2 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -544,7 +544,7 @@ int main (int argc, char ** argv)
/* If using cluster allocations, trim down to a cluster boundary */
if (ext2fs_has_feature_bigalloc(fs->super)) {
- new_size &= ~((blk64_t)(1 << fs->cluster_ratio_bits) - 1);
+ new_size &= ~((blk64_t)(1ULL << fs->cluster_ratio_bits) - 1);
}
new_group_desc_count = ext2fs_div64_ceil(new_size -