tcpheader: Fix BOOST_ASSERT failure in calculate_checksum
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 27 Dec 2025 17:28:09 +0000 (18:28 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 27 Dec 2025 17:28:09 +0000 (18:28 +0100)
commit2fb53a08f5529e3eea09fba29abd7a8ab3af9a1b
tree70301045c25715dd4fcbb92e810863181a672a6b
parent548f8eadb065af1585be31759186dfb1b26e8191
tcpheader: Fix BOOST_ASSERT failure in calculate_checksum

The assertion (sizeof(current_size) / 2) >= sizeof(size) was failing on
64-bit systems because:
- current_size was int64_t (8 bytes), so sizeof(current_size)/2 = 4
- size was size_t (8 bytes), so sizeof(size) = 8
- 4 >= 8 is false

Fix by:
- Using size_t for current_size to match the size parameter type
- Simplifying the assertion to check that current_size can hold size
- Simplifying the size decrement since both are now size_t

Test: test_tcpheader/calculate_tcp_checksum_ipv4 now passes
src/tcp/tcpheader.cpp