pellegre / libcrafter

A high level C++ network packet sniffing and crafting library.
298 stars 88 forks source link

Out of memory in ARPSpoofing.cpp #38

Closed dsxack closed 9 years ago

dsxack commented 9 years ago
node(31132,0x7fff730ba300) malloc: *** mach_vm_map(size=2305843009230548992) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc

out of memory in code: https://github.com/pellegre/libcrafter/blob/master/libcrafter/crafter/Utils/ARPSpoofing.cpp#L81

    for(it = TargetMACs->begin() ; it != TargetMACs->end() ; it++) {
        if( (*it) == AttackerMAC ) {
            it = TargetMACs->erase(it);

            /* And erase it from IP list */
            TargetIPs->erase(TargetIPs->begin() + count);
        }
        count++;
    }

First iteration of loop is normal. When second iteration - it is out of memory.

I think that in an iterator just one element that we remove with the help of erase and then get out of memory when the second iteration

oliviertilmans commented 9 years ago

Fixed by d0ab0a20e27c1