fix septentrio: check for buffer underflow

_message.header.length - 4 is passed as unsigned to the CRC method, so if
_message.header.length < 4, the length wraps and causes invalid memory
access.
This commit is contained in:
Beat Küng 2025-06-13 14:15:38 +02:00 committed by Alexander Lerach
parent 6f81998e27
commit 310cbbedb1

View File

@ -262,7 +262,7 @@ bool Decoder::done() const
bool Decoder::can_parse() const
{
return done() && _message.header.length <= sizeof(_message)
return done() && _message.header.length <= sizeof(_message) && _message.header.length > 4
&& _message.header.crc == buffer_crc16(reinterpret_cast<const uint8_t *>(&_message) + 4, _message.header.length - 4);
}