[Ocfs2-tools-devel] [PATCH] tunefs.ocfs2: fix a potential overflowing problem in check_new_size
piaojun
piaojun at huawei.com
Tue May 24 07:24:42 PDT 2016
Potentially overflowing expression "0xffffffffU << b_to_c_bits" with
type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit
arithmetic before being used in a context which expects an expression
of type "uint64_t" (64 bits, unsigned). To avoid overflow, cast the left
operand to "uint64_t" before performing the left shift.
Fixes: 15f01d8d8c1c ("tunefs.ocfs2: Warn if not using complete device")
Signed-off-by: Jun Piao <piaojun at huawei.com>
---
tunefs.ocfs2/op_resize_volume.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tunefs.ocfs2/op_resize_volume.c b/tunefs.ocfs2/op_resize_volume.c
index 076bda0..84d8628 100644
--- a/tunefs.ocfs2/op_resize_volume.c
+++ b/tunefs.ocfs2/op_resize_volume.c
@@ -543,7 +543,7 @@ static errcode_t check_new_size(ocfs2_filesys *fs, uint64_t new_size,
"Clusters (%"PRIu64" is greater than "
"maximum possible clusters %"PRIu32"\n",
device_clusters, UINT32_MAX);
- try_blocks = UINT32_MAX << b_to_c_bits;
+ try_blocks = (uint64_t)UINT32_MAX << b_to_c_bits;
errorf("Clusters %"PRIu64" is greater than max allowed"
" %"PRIu32".\nIf you want to resize to %"PRIu64
" blocks please specify %"PRIu64" as "
--
1.8.4.3
More information about the Ocfs2-tools-devel
mailing list