Skip to content

Commit 303a0af

Browse files
finikorgcarlescufi
authored andcommitted
net: tcp: Make sure we shift by less then bit width
Shifting "timeout <<= conn->zwp_retries" by more then 63 bits results in undefined behaviour. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
1 parent 42b121e commit 303a0af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/net/ip/tcp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,8 @@ static void tcp_send_zwp(struct k_work *work)
14041404
if (conn->send_win == 0) {
14051405
uint64_t timeout = TCP_RTO_MS;
14061406

1407-
/* Make sure the retry counter does not overflow. */
1408-
if (conn->zwp_retries < UINT8_MAX) {
1407+
/* Make sure the bitwise shift does not result in undefined behaviour */
1408+
if (conn->zwp_retries < 63) {
14091409
conn->zwp_retries++;
14101410
}
14111411

0 commit comments

Comments
 (0)