From 7b77210740e9cd201312a7eac475048858251dca Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 4 Sep 2014 14:58:50 +0200 Subject: [PATCH] objectstore/store_test.cc: fix unintentional integer overflow CID 1232603 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression objs_per_folder * folders_range(rng) with type int (32 bits, signed) 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 either operand to uint64_t before performing the multiplication. Signed-off-by: Danny Al-Gaaf --- src/test/objectstore/store_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index b11641de9edd..c997825edeb3 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -135,7 +135,7 @@ TEST_P(StoreTest, SimpleColPreHashTest) { int objs_per_folder = abs(merge_threshold) * 16 * g_ceph_context->_conf->filestore_split_multiple; boost::uniform_int<> folders_range(5, 256); - uint64_t expected_num_objs = (uint64_t)(objs_per_folder * folders_range(rng)); + uint64_t expected_num_objs = (uint64_t)objs_per_folder * (uint64_t)folders_range(rng); char buf[100]; snprintf(buf, 100, "1.%x_head", pg_id); -- 2.47.3