Skip to content

Commit 3703940

Browse files
committed
osdc/Striper.cc: fix OVERFLOW_BEFORE_WIDEN
Fix for: CID 1247719 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression stripe_count * object_size 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]>
1 parent d4b8d90 commit 3703940

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/osdc/Striper.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ uint64_t Striper::get_num_objects(const ceph_file_layout& layout, uint64_t size)
218218
__u32 object_size = layout.fl_object_size;
219219
__u32 stripe_unit = layout.fl_stripe_unit;
220220
__u32 stripe_count = layout.fl_stripe_count;
221-
uint64_t period = stripe_count * object_size;
221+
uint64_t period = (uint64_t)stripe_count * object_size;
222222
uint64_t num_periods = (size + period - 1) / period;
223223
uint64_t remainder_bytes = size % period;
224224
uint64_t remainder_objs = 0;

0 commit comments

Comments
 (0)