Skip to content

Commit d871889

Browse files
committed
osdc/Striper.cc: fix another OVERFLOW_BEFORE_WIDEN
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>
1 parent 3703940 commit d871889

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/osdc/Striper.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ uint64_t Striper::get_num_objects(const ceph_file_layout& layout, uint64_t size)
222222
uint64_t num_periods = (size + period - 1) / period;
223223
uint64_t remainder_bytes = size % period;
224224
uint64_t remainder_objs = 0;
225-
if ((remainder_bytes > 0) && (remainder_bytes < stripe_count * stripe_unit))
225+
if ((remainder_bytes > 0) && (remainder_bytes < (uint64_t)stripe_count * stripe_unit))
226226
remainder_objs = stripe_count - ((remainder_bytes + stripe_unit - 1) / stripe_unit);
227227
return num_periods * stripe_count - remainder_objs;
228228
}

0 commit comments

Comments
 (0)