Closed a-higuchi closed 2 years ago
Sorry, I didn't realize I was still a maintiner on this project!
@JWhitleyWork Thanks for taking a look at this. Since you are no longer an AWF employee, I have removed you from the maintainer for now and assigned others from AWF. If you still wish to continue as a maintainer, please let me know.
@mitsudome-r Yes, I would appreciate staying as a maintainer. I'm fine collaborating with the AWF but I'm still actively using and developing this project and am willing to help review PRs.
Relate https://github.com/autowarefoundation/ros2_socketcan/issues/17
Description
If the DLC(Data Length Code) is less than 8, the previously received data remains in the "data" field of the topic sent by ros2_socketcan.
When supporting multiple types of HW with the same CAN-ID but different DLCs(*see below for further details), unintended behavior may occur if garbage is included in the reception result of can_receiver.
*Description about "CAN-ID but different DLCs". For example, there are two HWs, HW1 and HW2, and the specification of HW1's CAN-ID: 100h is as follows.
In contrast to the above, if the HW2 CAN-ID: 100h specification is as follows, a malfunction may occur if the previously received data remains in the "data" field.
Current problem
The data length for memcopy was the DLC value in
SocketCanReceiver::receive
.As a result, when receiving data with a DLC length of less than 8, the data after the DLC data length was not initialized, and the previously received data remained in the buffer.
Countermeasures
Fixed data length to memcopy to be the size of the data field.
Review Procedure
I have confirmed that the unused data fields have been initialized by the steps described in the issue.