Skip to content

Commit 344012b

Browse files
committed
Fix the issue that WinDump fails to run on default adapter with no arguments, see: the-tcpdump-group/libpcap#562
1 parent 5dffebe commit 344012b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Tcpdump.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,20 @@ main(int argc, char **argv)
889889
error("-f and -r options are incompatible");
890890
} else {
891891
if (device == NULL) {
892-
device = pcap_lookupdev(ebuf);
893-
if (device == NULL)
892+
// pcap_lookupdev() will return Unicode string,
893+
// which will cause fault if passed to pcap_open() which accepts ASCII.
894+
// So we don't use it any more.
895+
// See: https://github.com/the-tcpdump-group/libpcap/issues/562
896+
// device = pcap_lookupdev(ebuf);
897+
// if (device == NULL)
898+
// error("%s", ebuf);
899+
900+
if (pcap_findalldevs(&devpointer, ebuf) < 0)
894901
error("%s", ebuf);
902+
if (devpointer == NULL)
903+
error("%s", "no adapter available");
904+
905+
device = devpointer->name;
895906
}
896907
#ifdef WIN32
897908
if(strlen(device) == 1) //we assume that an ASCII string is always longer than 1 char

0 commit comments

Comments
 (0)