mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
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:
parent
6f81998e27
commit
310cbbedb1
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user