meh / rust-packet

Network packet handling for Rust.
90 stars 27 forks source link

fix(tcp checksum): fix tcp checksum on odd length buffer #18

Closed kurikomoe closed 1 year ago

kurikomoe commented 1 year ago

Fix tcp checksum calculation error when the buffer length is not even.

on my project, I found that the tcp checksum is incorrect. After some analysis, it seems that the read_u16 (which is based on read_exact) will raise an eof error on odd length buffer thus make the last byte not be calculated.