From: Guy Harris Date: Sat, 9 Jun 2012 18:12:55 +0000 (-0700) Subject: Don't just treat anything that contains "can" or "vcan" as a CANbus device. X-Git-Tag: libpcap-1.3.0~1 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/2a74cb1ec2057f959050c6d05b732be246a30f61?ds=sidebyside Don't just treat anything that contains "can" or "vcan" as a CANbus device. Instead, require that it *start* with "can" or "vcan", and be followed by at least one digit. This means that if you, for example, rename a regular interface as, for example, "canopy", it will no longer be mistakenly treated as a CANbus device (yes, this really happened, and a bug was filed against it). --- diff --git a/pcap-linux.c b/pcap-linux.c index 3994c30a..8d131cf1 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -428,9 +428,9 @@ pcap_create(const char *device, char *ebuf) } #endif - #ifdef PCAP_SUPPORT_CAN - if (strstr(device, "can") || strstr(device, "vcan")) { + if ((strncmp(device, "can", 3) == 0 && isdigit(device[3])) || + (strncmp(device, "vcan", 4) == 0 && isigit(device[4]))) { return can_create(device, ebuf); } #endif