Browse Source

plugins/channelrx/demodm17: Avoid negative indexing in checksum extraction

Fix Coverity CID 655947 by replacing end()[-2] with an
explicit size-based index when extracting the transmitted
checksum. This avoids passing a negative index to the
container access expression.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.1.0
Robin Getz 4 weeks ago
parent
commit
b86f8e8a1d
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 2
      plugins/channelrx/demodm17/m17demodprocessor.cpp

2
plugins/channelrx/demodm17/m17demodprocessor.cpp

@ -344,7 +344,7 @@ bool M17DemodProcessor::decode_packet(modemm17::M17FrameDecoder::packet_buffer_t @@ -344,7 +344,7 @@ bool M17DemodProcessor::decode_packet(modemm17::M17FrameDecoder::packet_buffer_t
}
uint16_t calcChecksum = crc16.get_bytes()[1] + (crc16.get_bytes()[0]<<8);
uint16_t xmitChecksum = m_currentPacket.back() + (m_currentPacket.end()[-2]<<8);
uint16_t xmitChecksum = m_currentPacket.back() + (m_currentPacket[m_currentPacket.size() - 2] << 8);
if (calcChecksum == xmitChecksum) // (checksum == 0x0f47)
{

Loading…
Cancel
Save