Enforce that CANMessage.m_dataSize won't be larger than 8 bytes #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, the actual data array in
CANMessage
was always limited to 8 bytes, butm_dataSize
could be larger than that, which could trick consumers of this library into reading from an invalid memory location.Marking this as a draft*, because I think
CandleWinUsbDeviceThread
suffers from a similar issue. Thedata
field oncandle_frame_t
(which represents the actual format of the USB packet) always has a length of8
, but it's possible for thedlc
sent over CAN to be higher than that. This line of code should not assume thatframe.data
is at least as large asframe.can_dlc
:CANBridge/src/main/native/include/rev/Drivers/CandleWinUSB/CandleWinUSBDeviceThread.h
Line 189 in 8d0f4f6
We should also determine whether
gs_usb
devices populateframe.can_dlc
values larger than 8 as their over-the-CAN-bus format of 4 bits, or whether they handle expanding that to the actual size (DLC values ranging from1001
to1111
are used to specify data lengths of 12, 16, 20, 24, 32, 48, and 64 bytes, respectively), as that will influence that logic.*also, it doesn't currently compile