tcpdump mailing list archives
Re: Libpcap - pcapfindalldevs
From: Johan Mazel <johan.mazel () gmail com>
Date: Fri, 4 Sep 2009 17:47:53 +0200
Sorry for the second mail Correction : My machine runs on Ubuntu 9.04. My libpcap version is 1.0.0-1. Johan Mazel 2009/9/4 Johan Mazel <johan.mazel () gmail com>
I wrote a short piece of code in C to show the problem. My code is the following one: *#include <stdio.h> #include <pcap.h> int main(){ struct pcap_if * found_devices; int result; char * errbuf; printf("Scanning\n"); result = pcap_findalldevs(&found_devices, errbuf); printf("Scan finished\n"); if(result < 0) { printf("Device scan error %s\n",errbuf); return -1; } while(found_devices != NULL) { printf("%s\n",found_devices->name); found_devices = found_devices->next; } return 0; }* I compiled it with this line: gcc -g -lpcap scan_devices.c -o scan_devices Then, I ran it in gdb with this line: run scan_devices. The error message is the following one: Starting program: /.../Programmes/Tests/Scan_Interfaces/scan_devices scan_devices Scanning Program received signal SIGSEGV, Segmentation fault. 0x00007fec3290afc1 in strncpy () from /lib/libc.so.6 The command bt gave me this answer: #0 0x00007fec3290afc1 in strncpy () from /lib/libc.so.6 #1 0x00007fec32c07f1c in pcap_open_live () from /usr/lib/libpcap.so.0.8 #2 0x00007fec32c0828c in add_or_find_if () from /usr/lib/libpcap.so.0.8 #3 0x00007fec32c0853e in add_addr_to_iflist () from /usr/lib/libpcap.so.0.8 #4 0x00007fec32c06fce in pcap_findalldevs () from /usr/lib/libpcap.so.0.8 #5 0x00000000004006db in main () at scan_devices.c:9 It looks like the pcap_findalldevs function of libpcap try to open each device (through the pcap_open_live) and thus provoke an error if the program is not run as root. My machine runs on Ubuntu 8.10. My libpcap version is 0.9.8-5. The command gcc -v gives me: Utilisation des specs internes. Target: x86_64-linux-gnu Configuré avec: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Modèle de thread: posix gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) The command gdb -v gives me: GNU gdb 6.8-debian Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later < http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". If this is a bug in Libpcap, how can I submit it ? Regards. Johan 2009/2/2 Guy Harris <guy () alum mit edu>On Feb 2, 2009, at 5:39 AM, Johan Mazel wrote: My problem is that when I'm not running the program as root, I got the"Erreur de bus" in French (or "Bus Error" in english I guess) and my program suddenly stops.That is either a bug in your program, a bug in libpcap, or a bug in some other piece of software. You'd have to run your program under a debugger to see where it crashes in order to determine where the bug is and either 1) fix it if it's in your program or 2) report it if it's a bug in some other piece of software. - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Re: Libpcap - pcapfindalldevs Johan Mazel (Sep 07)
- Re: Libpcap - pcapfindalldevs Johan Mazel (Sep 07)
- Re: Libpcap - pcapfindalldevs Guy Harris (Sep 07)
- Re: Libpcap - pcapfindalldevs Johan Mazel (Sep 07)