From 6f995547fe5e346ce477268394605a27348b7e24 Mon Sep 17 00:00:00 2001 From: jxltom Date: Thu, 12 Mar 2020 14:24:31 +0800 Subject: [PATCH] Avoid overflow when can frame dlc is not set correctly --- mcp2515.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mcp2515.cpp b/mcp2515.cpp index 833a133..88c91b2 100644 --- a/mcp2515.cpp +++ b/mcp2515.cpp @@ -573,6 +573,10 @@ MCP2515::ERROR MCP2515::setFilter(const RXF num, const bool ext, const uint32_t MCP2515::ERROR MCP2515::sendMessage(const TXBn txbn, const struct can_frame *frame) { + if (frame->can_dlc > CAN_MAX_DLEN) { + return ERROR_FAILTX; + } + const struct TXBn_REGS *txbuf = &TXB[txbn]; uint8_t data[13];