analogdevicesinc / msdk

Software Development Kit for Analog Device's MAX-series microcontrollers
Apache License 2.0
60 stars 75 forks source link

Buffer overflow in MXC_SYS_GetUSN / sys_me15.c #1006

Closed pedrofza closed 2 weeks ago

pedrofza commented 2 months ago

Board

Files:

Affected versions that I checked:

The docstring for MXC_SYS_GetUSN states that the parameter usn must be at least MXC_SYS_USN_LEN (13) bytes long.

However, it looks like the implementation in sys_me15.c will unconditionally memset the first MXC_SYS_USN_CHECKSUM_LEN (16) bytes of usn, resulting in a buffer overflow if usn has the minimum size of MXC_SYS_USN_LEN bytes, as stated in the docstring.

Jake-Carter commented 1 month ago

Thanks @pedrofza - you're right, good catch. Just opened a PR to use the correct value.