]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Striper.cc: fix another OVERFLOW_BEFORE_WIDEN
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 12 Mar 2015 21:56:22 +0000 (22:56 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 17 Mar 2015 08:19:39 +0000 (09:19 +0100)
Fix for:

CID 1247720 (#1 of 1): Unintentional integer overflow
(OVERFLOW_BEFORE_WIDEN)
 overflow_before_widen: Potentially overflowing expression
 stripe_count * stripe_unit 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).

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/osdc/Striper.cc

index a033fc0fb0d28566f29b7311a82f39bb3968eb60..cca7686ca90c2a036a6043ac0a48e68318672a45 100644 (file)
@@ -222,7 +222,7 @@ uint64_t Striper::get_num_objects(const ceph_file_layout& layout, uint64_t size)
   uint64_t num_periods = (size + period - 1) / period;
   uint64_t remainder_bytes = size % period;
   uint64_t remainder_objs = 0;
-  if ((remainder_bytes > 0) && (remainder_bytes < stripe_count * stripe_unit))
+  if ((remainder_bytes > 0) && (remainder_bytes < (uint64_t)stripe_count * stripe_unit))
     remainder_objs = stripe_count - ((remainder_bytes + stripe_unit - 1) / stripe_unit);
   return num_periods * stripe_count - remainder_objs;
 }