Skip to content

Commit

Permalink
osdc/Striper.cc: fix another OVERFLOW_BEFORE_WIDEN
Browse files Browse the repository at this point in the history
Fix for:

CID 1247720 (ceph#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 <[email protected]>
  • Loading branch information
dalgaaf committed Mar 17, 2015
1 parent 3703940 commit d871889
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/osdc/Striper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d871889

Please sign in to comment.