-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Description of defect
The code responsible for handling incoming CAN messages allows DLC field values higher than 8. This is not in-line with the standard CAN protocol (such values are only used in CAN-FD). This report is created since several issues where developers assumed that the DLC value is maximum of 8 were found. Example of such an issue could be a simple memcpy operation like this:
memcpy(dest_buffer,can_msg.data,can_msg.len)
In such situation sending an arbitrary CAN message with DLC set to maximum value (15) would cause a buffer overflow.
Target(s) affected by this defect ?
Any code using CAN bus from MbedOS.
Toolchain(s) (name and version) displaying this defect ?
CAN interface handler
What version of Mbed-os are you using (tag or sha) ?
All versions of MbedOS up to current (https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.16.0)
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
Not Applicable
How is this defect reproduced ?
Any code working with CAN messages on the receiving end (example below was used in the PoC - see the attached screenshot). The sending side could be any Arduino board with CAN controller.
#include "mbed.h"
CAN can1(PB_8, PB_9);
// main() runs in its own thread in the OS
int main()
{
CANMessage msg;
printf("main()\n");
can1.frequency(500000);
while (true) {
if (can1.read(msg)) {
printf("Message received:\n ID: %d\n DLC: %d\n", msg.id,msg.len);
}
}
}