I've been testing latest libpcap and tcpdump on the Ubuntu Lucid beta.
When tcpdump is run with no arguments, or with just the -D argument, it segfaults. I've traced the error through the tcpdump source to either of the two functions above, but am not familiar enough with libpcap to go any farther.
This problem does not exist with libpcap 1.0.0.
Try running the latest tcpdump under gdb, with the -D argument, and see what gdb reports.
I can't reproduce this on my Ubuntu 9.10 VM; this might be something that a later version of Ubuntu introduces, *or* it might be the result of a difference between the network interfaces on the two machines.
I had the same problem today when coding a simple c app using pcap. pcap_findalldevs() would cause a segmentation fault. I had to run as root.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
The problem is this in pcap-linux.c:
sys_class_net_d = opendir("/sys/class/net");
if (sys_class_net_d == NULL && errno == ENOENT)
return (0);
The errno check is unnecessary; opendir() may fail for other reasons, and if the code is allowed to continue, it will then SEGV trying to readdir(sys_class_net_d) few lines down.
A common cause may be /sys not being readable to the current user:
9954 open("/sys/class/net", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 EACCES (Permission denied)
9954 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
9954 --- SIGSEGV (Segmentation fault) @ 0 (0) ---
9954 +++ killed by SIGSEGV +++
Last edit: Anonymous 2014-04-01
Dup of
https://sourceforge.net/tracker/?func=detail&aid=3409083&group_id=53067&atid=469579
Administrators of the "libpcap" SourceForge project have superseded this tracker item (formerly artifact 2988810, now bug 134) with issue 136 of the "libpcap" GitHub project.