Otherwise integer overflows can happen. Remember, doing a i32xi32
multiply doesn't actually produce a 64-bit output. You need to do
i64xi32 or i64xi64.
Coverity found this as CID
1417753
/* Assuming all these values from the kernel are uint32_t still, they will
* always fit into a int64_t tcp_space variable. */
- tcp_space = (ent->cwnd - ent->unacked) * ent->mss;
+ tcp_space = (ent->cwnd - ent->unacked) * (int64_t)ent->mss;
if (tcp_space < 0) {
tcp_space = 0;
}
* we end up negative, but then we just set extra_space to 0 in the sanity
* check.*/
extra_space =
- clamp_double_to_int64((ent->cwnd * ent->mss) * sock_buf_size_factor) -
+ clamp_double_to_int64(
+ (ent->cwnd * (int64_t)ent->mss) * sock_buf_size_factor) -
ent->notsent;
if (extra_space < 0) {
extra_space = 0;