Revert "cangen: use if_nametoindex() to avoid overflows"

This reverts commit 1f96d674c0.

Link: https://github.com/linux-can/can-utils/pull/396
Link: 1f96d674c0 (commitcomment-97455025)
pull/399/head
Marc Kleine-Budde 2023-01-20 09:32:49 +01:00 committed by Oliver Hartkopp
parent 5aa72c5e9e
commit 77ec9b3c2d
1 changed files with 5 additions and 3 deletions

View File

@ -608,11 +608,13 @@ int main(int argc, char **argv)
}
addr.can_family = AF_CAN;
addr.can_ifindex = if_nametoindex(argv[optind]);
if (!addr.can_ifindex) {
perror("if_nametoindex");
strcpy(ifr.ifr_name, argv[optind]);
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
perror("SIOCGIFINDEX");
return 1;
}
addr.can_ifindex = ifr.ifr_ifindex;
/*
* disable default receive filter on this RAW socket