]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
objectstore/store_test.cc: fix unintentional integer overflow
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 4 Sep 2014 12:58:50 +0000 (14:58 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 4 Sep 2014 12:58:50 +0000 (14:58 +0200)
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 <danny.al-gaaf@bisect.de>
src/test/objectstore/store_test.cc

index b11641de9edd67d3be6676d764e9ae8c1a93fc88..c997825edeb352274cca41b454de66d6df0c3419 100644 (file)
@@ -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);