From 6b70483232de10d67f6b4533be691dfcd4d31565 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 4 Sep 2014 14:36:18 +0200 Subject: [PATCH] os/HashIndex.cc: fix unintentional integer overflow CID 1232604 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression (unsigned int)abs(this->merge_threshold) * 16U * this->split_multiplier 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 const (64 bits, unsigned). To avoid overflow, cast either operand to uint64_t const before performing the multiplication. Signed-off-by: Danny Al-Gaaf --- src/os/HashIndex.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/HashIndex.cc b/src/os/HashIndex.cc index 706d75ada1764..ca0b591a9162e 100644 --- a/src/os/HashIndex.cc +++ b/src/os/HashIndex.cc @@ -375,7 +375,7 @@ int HashIndex::pre_split_folder(uint32_t pg_num, uint64_t expected_num_objs) // Calculate the number of leaf folders (which actually store files) // need to be created - const uint64_t objs_per_folder = (unsigned)(abs(merge_threshold)) * 16 * split_multiplier; + const uint64_t objs_per_folder = (uint64_t)(abs(merge_threshold)) * (uint64_t)split_multiplier * 16; uint64_t leavies = expected_num_objs / objs_per_folder ; // No need to split if (leavies == 0 || expected_num_objs == objs_per_folder) -- 2.39.5