]> The Tcpdump Group git mirrors - libpcap/commitdiff
Don't just treat anything that contains "can" or "vcan" as a CANbus device.
authorGuy Harris <[email protected]>
Sat, 9 Jun 2012 18:12:55 +0000 (11:12 -0700)
committerGuy Harris <[email protected]>
Sat, 9 Jun 2012 18:12:55 +0000 (11:12 -0700)
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).

pcap-linux.c

index 3994c30a03f691fc1f35f6c6ae85fafa3f8e9793..8d131cf1cf13430327a257dad7be34563d025f08 100644 (file)
@@ -428,9 +428,9 @@ pcap_create(const char *device, char *ebuf)
   }
 #endif
 
   }
 #endif
 
-
 #ifdef PCAP_SUPPORT_CAN
 #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
                return can_create(device, ebuf);
        }
 #endif