| 1 | --- a/tcpdump.c |
| 2 | +++ b/tcpdump.c |
| 3 | @@ -66,6 +66,7 @@ extern int SIZE_BUF; |
| 4 | #include <stdlib.h> |
| 5 | #include <string.h> |
| 6 | #include <limits.h> |
| 7 | +#include <ctype.h> |
| 8 | #ifndef WIN32 |
| 9 | #include <sys/wait.h> |
| 10 | #include <sys/resource.h> |
| 11 | @@ -625,6 +626,7 @@ main(int argc, char **argv) |
| 12 | #ifdef HAVE_PCAP_FINDALLDEVS |
| 13 | pcap_if_t *devpointer; |
| 14 | int devnum; |
| 15 | + char *devp; |
| 16 | #endif |
| 17 | int status; |
| 18 | #ifdef WIN32 |
| 19 | @@ -775,7 +777,8 @@ main(int argc, char **argv) |
| 20 | * It can be useful on Windows, where more than |
| 21 | * one interface can have the same name. |
| 22 | */ |
| 23 | - if ((devnum = atoi(optarg)) != 0) { |
| 24 | + for (devp = optarg; *devp && isdigit(*devp); devp++); |
| 25 | + if ((!*devp || isspace(*devp)) && (devnum = atoi(optarg)) != 0) { |
| 26 | if (devnum < 0) |
| 27 | error("Invalid adapter index"); |
| 28 | |
| 29 | |