diff options
| author | babenko <[email protected]> | 2026-04-20 10:51:19 +0300 |
|---|---|---|
| committer | babenko <[email protected]> | 2026-04-20 11:25:53 +0300 |
| commit | 07606a65bc35df5a2c357217e9e76290792e20b2 (patch) | |
| tree | de6e41a74ac3980218f9eed163673ef4cecb9a5c /library/cpp/yt/string/string.cpp | |
| parent | 4e3178e1b19fe0b278631dfc888e902c4f8163c8 (diff) | |
Fix off-by-one in retransmit counter overflow handling in TTcpConnection
The previous formula `new + (Max<ui32>() - old)` is off by one on wraparound:
when the counter goes from `old=5` to `new=2` after wrapping through zero the
true delta is `Max<ui32>() - 5 + 1 + 2`, but the formula gives
`Max<ui32>() - 3` instead of `Max<ui32>() - 2`.
Replaced with a plain unsigned subtraction via `static_cast<ui32>(new - old)`,
which handles overflow correctly by construction: C++ unsigned arithmetic wraps
modulo 2³², so the result is always the right delta regardless of whether the
counter wrapped.
commit_hash:f4aa45770c912ae53907b70cc1130c4822140e9f
Diffstat (limited to 'library/cpp/yt/string/string.cpp')
0 files changed, 0 insertions, 0 deletions
