Skip to content

Commit 4fb47a6

Browse files
csanchezdllxiaoxiang781216
authored andcommitted
canutils/slcan: Work with CAN interfaces with names longer than 4 characters.
Signed-off-by: Carlos Sanchez <[email protected]>
1 parent 5585c9d commit 4fb47a6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

canutils/slcan/slcan.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ static int caninit(char *candev, int *s, struct sockaddr_can *addr,
137137
syslog(LOG_ERR, "Error opening CAN socket\n");
138138
return -1;
139139
}
140-
strncpy(ifr.ifr_name, candev, 4);
141-
ifr.ifr_name[4] = '\0';
140+
strlcpy(ifr.ifr_name, candev, IFNAMSIZ);
142141
ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name);
143142
if (!ifr.ifr_ifindex)
144143
{

0 commit comments

Comments
 (0)