2

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

 Crafter::GetMAC("192.168.1.10", "eth0");

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

  - Crafter::GetMAC("192.168.1.10", "eth0");
  - 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?

wasp256
  • 5,943
  • 12
  • 72
  • 119
  • Due to using a null pointer. iterator should be given a value before being used. – QuentinUK Mar 12 '15 at 00:09
  • The iterator is not null, I have tried it also with hardcoded values. Updated the post, sorry for the confusion, but still get the same result – wasp256 Mar 12 '15 at 07:45
  • PacketFromIP just calls Decode, Decode deletes the layers. It could be there, if a layer on the stack is a null ptr? – QuentinUK Mar 12 '15 at 09:10

0 Answers0