Skip to content

Commit

Permalink
πŸ›: properly copy can interface name
Browse files Browse the repository at this point in the history
closes #58
  • Loading branch information
mguentner committed Nov 18, 2023
1 parent 7f71dea commit a2cf333
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion canthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ int CANThread::start() {
return -1;
}
/* Determine the index of m_canInterfaceName */
strncpy(canInterface.ifr_name, m_canInterfaceName.c_str(), IFNAMSIZ);
strncpy(canInterface.ifr_name, m_canInterfaceName.c_str(), IFNAMSIZ-1);
canInterface.ifr_name[IF_NAMESIZE-1] = '\0';
if (ioctl(m_canSocket, SIOCGIFINDEX, &canInterface) < 0) {
lerror << "Could get index of interface >" << m_canInterfaceName << "<" << std::endl;
return -1;
Expand Down

0 comments on commit a2cf333

Please sign in to comment.