Skip to content

Commit 6f99554

Browse files
authored
Avoid overflow when can frame dlc is not set correctly
1 parent 9ecc5a8 commit 6f99554

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mcp2515.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ MCP2515::ERROR MCP2515::setFilter(const RXF num, const bool ext, const uint32_t
573573

574574
MCP2515::ERROR MCP2515::sendMessage(const TXBn txbn, const struct can_frame *frame)
575575
{
576+
if (frame->can_dlc > CAN_MAX_DLEN) {
577+
return ERROR_FAILTX;
578+
}
579+
576580
const struct TXBn_REGS *txbuf = &TXB[txbn];
577581

578582
uint8_t data[13];

0 commit comments

Comments
 (0)