mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
drivers/can/ctucanfd_pci: Fix Malformed CAN Data Msg (address off-by-one)
PR https://github.com/apache/nuttx/pull/19139 addresses the issue, but there is one minor problem. In the for loop the element `i+1` is written which means there can still be an overflow by one element (uint32_t or 4 bytes). Addressing here with this PR. Tested locally, builds fine. Signed-off-by: Catalin Visinescu <catalin_visinescu@yahoo.com>
This commit is contained in:
parent
5c8fa78c4e
commit
b840bf6552
1 changed files with 2 additions and 2 deletions
|
|
@ -762,7 +762,7 @@ static void ctucanfd_chardev_receive(FAR struct ctucanfd_can_s *priv)
|
|||
|
||||
/* buff[0] populated the frame->fmt.rwcnt. Check before use. */
|
||||
|
||||
if (frame->fmt.rwcnt > sizeof(buff) / sizeof(buff[0]))
|
||||
if (frame->fmt.rwcnt > sizeof(buff) / sizeof(buff[0]) - 1)
|
||||
{
|
||||
canerr("ERROR: CAN read/write count is too large. Dropped\n");
|
||||
return;
|
||||
|
|
@ -1259,7 +1259,7 @@ static FAR netpkt_t *ctucanfd_sock_recv(FAR struct netdev_lowerhalf_s *dev)
|
|||
|
||||
/* buff[0] populated the frame->fmt.rwcnt. Check before use. */
|
||||
|
||||
if (frame->fmt.rwcnt > sizeof(buff) / sizeof(buff[0]))
|
||||
if (frame->fmt.rwcnt > sizeof(buff) / sizeof(buff[0]) - 1)
|
||||
{
|
||||
canerr("ERROR: CAN read/write count is too large. Dropped\n");
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue