BUG/MINOR: peers: reject message lengths above 32 bits before truncation
peer_recv_msg() decodes the stick-table message length with intdecode(),
which returns a 64-bit value, and stores it into a uint32_t before
checking it against the buffer size. The length is encoded on at most 5
bytes here, so it can reach
4328786159 (2^32 +
33818863). Such values
wrap to 0..
33818863 when truncated, pass the size check, and desync the
parsing of the stream instead of being rejected.
Decode into a 64-bit local variable and compare it to trash.size before
storing it, so oversized lengths are now reported as ERRSIZE.
This only triggers on a malformed length sent by a configured peer,
i.e. a buggy or malicious one: a compliant peer never encodes such a
value, and peer sessions are expected to run on trusted networks. The
impact is limited to garbling that session; there is no buffer write
overflow, as only the truncated length is ever used to read data.
This has been there for a long time and can be backported to all stable.