Skip to content

Commit a00d5db

Browse files
authored
Merge pull request #33 from jxltom/jxltom-patch-2
Avoid overflow when Can frame DLC is not set correctly
2 parents 9ecc5a8 + 6f99554 commit a00d5db

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)