Skip to content

Commit

Permalink
Update ros2_socketcan/src/socket_can_receiver.cpp
Browse files Browse the repository at this point in the history
Co-authored-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
knzo25 and xmfcx authored Sep 25, 2024
1 parent 39ada3d commit 36738f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ros2_socketcan/src/socket_can_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ CanId SocketCanReceiver::receive_fd(void * const data, const std::chrono::nanose
throw std::runtime_error{strerror(errno)};
}

if (frame.len > CANFD_MAX_DLEN) {
throw std::runtime_error{"read: frame length is larger than max allowed CAN FD payload length"};
}

if (static_cast<std::size_t>(nbytes) < sizeof(frame.can_id) + sizeof(frame.len)) {
throw std::runtime_error{"read: corrupted CAN frame"};
}
Expand Down

0 comments on commit 36738f5

Please sign in to comment.