From: Danny Al-Gaaf Date: Thu, 4 Sep 2014 12:36:18 +0000 (+0200) Subject: os/HashIndex.cc: fix unintentional integer overflow X-Git-Tag: v0.86~135^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b70483232de10d67f6b4533be691dfcd4d31565;p=ceph.git 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 --- diff --git a/src/os/HashIndex.cc b/src/os/HashIndex.cc index 706d75ada17..ca0b591a916 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)