Menu

#134 pcap_lookupdev and pcap_findalldevs segfault

v1.1
closed-duplicate
nobody
None
5
2013-11-20
2010-04-17
Anonymous
No

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.

Discussion

  • Guy Harris

    Guy Harris - 2010-04-17

    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.

     
  • NanoDano

    NanoDano - 2010-07-26

    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.

     
  • Anonymous

    Anonymous - 2011-12-27

    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
  • Guy Harris

    Guy Harris - 2011-12-27
    • status: open --> closed-duplicate
     
  • Denis Ovsienko

    Denis Ovsienko - 2013-11-20

    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.