Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Buffer Overrun in CANMessage Constructor #12311

Closed
daniel-starke opened this issue Jan 24, 2020 · 2 comments
Closed

Potential Buffer Overrun in CANMessage Constructor #12311

daniel-starke opened this issue Jan 24, 2020 · 2 comments

Comments

@daniel-starke
Copy link
Contributor

Description of defect

The CANMessage constructor takes data and length in two variants. Both variants limit the length to 8 byte when setting the internal length member but fail to use that instead of the unlimited input parameter _len when performing the memcpy() from the passed data pointer. This leads into a potential buffer overrun if an invalid data length is passed to the constructor. I suggest to use len instead of _len for memcpy() in both instances of the constructor. See source code.

Target(s) affected by this defect ?

Every target that supports the CAN bus.

Toolchain(s) (name and version) displaying this defect ?

None. This was found by manual code analysis.

What version of Mbed-os are you using (tag or sha) ?

mbed-os-99.99.99
sha: 5933dec

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

None.

How is this defect reproduced ?

Code analysis.

@ciarmcom
Copy link
Member

Internal Jira reference: https://jira.arm.com/browse/MBOTRIAGE-2521

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 4, 2020

@daniel-starke Thanks for the report. Can you please send a pull request fixing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants