Skip to content

Commit

Permalink
CANParser: fix can data size issue (commaai#799)
Browse files Browse the repository at this point in the history
fix can data size issues

Co-authored-by: Shane Smiskol <[email protected]>
  • Loading branch information
2 people authored and martinl committed Aug 29, 2024
1 parent e3c246a commit f027059
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions can/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ void CANParser::UpdateCans(uint64_t nanos, const capnp::List<cereal::CanData>::R
// DEBUG("got message with unexpected length: expected %d, got %zu for %d", state_it->second.size, dat.size(), cmsg.getAddress());
// continue;
//}

std::vector<uint8_t> data(dat.size(), 0);
// make sure the data_size if not less than state_it->second.size.
size_t data_size = std::max<size_t>(dat.size(), state_it->second.size);
std::vector<uint8_t> data(data_size, 0);
memcpy(data.data(), dat.begin(), dat.size());
state_it->second.parse(nanos, data);
}
Expand Down

0 comments on commit f027059

Please sign in to comment.