mercredi 11 mars 2015

c++ segmentation fault in libcrafter


I am using the library Crafter in my c++ program. When calling the function



Crafter::GetMAC(net_addr, iterator->iface_name);


I receive a Segmentation Fault, I looked into this method, which calls some other methods. The call stack is as follows:



- Crafter::GetMAC(net_addr, iterator->iface_name);
- GetMACIPv4(net_addr, iterator->iface_name);
- Packet::SendRecv(const string& iface, double timeout, int retry, const string& user_filter);


In the SendRecv I receive the Segmentation Fault at this line:



if ((r = pcap_next_ex (handle, &header, &packet)) <= 0)


I run the program with valgrind and the stacktrace output of the error I receive is the following:



==32555== Process terminating with default action of signal 11 (SIGSEGV)
==32555== Access not within mapped region at address 0x0
==32555== at 0x4E68DD0: Crafter::Packet::PacketFromIP(unsigned char const*, unsigned long) (PacketDecoder.cpp:599)
==32555== by 0x406EA2: captureThreadCallback(unsigned char*, pcap_pkthdr const*, unsigned char const*) (NetworkStructure.cpp:17)
==32555== by 0x50CE805: pcap_handle_packet_mmap (pcap-linux.c:4546)
==32555== by 0x50D31D0: pcap_read_linux_mmap_v3 (pcap-linux.c:4825)
==32555== by 0x50D76AC: pcap_loop (pcap.c:868)
==32555== by 0x406F65: captureThread(void*) (NetworkStructure.cpp:35)
==32555== by 0x53120A4: start_thread (pthread_create.c:309)
==32555== by 0x5B47CFC: clone (clone.S:111)


The installed version of libcrafter is 0.2, and from libpcap 1.6.2-1


Does anyone have an idea how to fix this?




Aucun commentaire:

Enregistrer un commentaire