CRSF: Validate unknown packet sizes to be smaller than max packet size

Co-authored-by: Chris Seto <chris1seto@gmail.com>
This commit is contained in:
chris1seto
2022-09-24 16:36:17 -04:00
committed by GitHub
co-authored by Chris Seto
parent 57bdac2b26
commit 770f8080c0
3 changed files with 11 additions and 0 deletions
+9
View File
@@ -294,6 +294,15 @@ bool CrsfParser_TryParseCrsfPacket(CrsfPacket_t *const new_packet, CrsfParserSta
// We don't know what this packet is, so we'll let the parser continue
// just so that we can dequeue it in one shot
working_segment_size = packet_size + PACKET_SIZE_TYPE_SIZE;
if (working_segment_size > CRSF_MAX_PACKET_LEN) {
parser_statistics->invalid_unknown_packet_sizes++;
parser_state = PARSER_STATE_HEADER;
working_segment_size = HEADER_SIZE;
working_index = 0;
buffer_count = QueueBuffer_Count(&rx_queue);
continue;
}
}
parser_state = PARSER_STATE_PAYLOAD;