Merge remote-tracking branch 'origin/topic/jazoff/packet-fuzzer'

* origin/topic/jazoff/packet-fuzzer:
  Update src/fuzzers/packet-fuzzer.cc
  Update src/fuzzers/packet-fuzzer.cc
  add initial packet corpus
  add packet fuzzer
This commit is contained in:
Jon Siwek 2020-05-18 10:47:54 -07:00
commit 2bac702a72
5 changed files with 58 additions and 1 deletions

11
CHANGES
View file

@ -1,4 +1,15 @@
3.2.0-dev.547 | 2020-05-18 10:47:54 -0700
* add packet fuzzer (Justin Azoff)
* Fix building fuzz targets on macOS (Jon Siwek, Corelight)
* Highwayhash: small build fix (Johanna Amann, Corelight)
Turns out that hh_neon should not be compiled on generic arm CPUs.
That one is only for aarch64.
3.2.0-dev.539 | 2020-05-15 19:47:55 +0000
* Replace bzero() with memset() (Noah Treuhaft)

View file

@ -1 +1 @@
3.2.0-dev.539
3.2.0-dev.547

View file

@ -79,3 +79,4 @@ target_link_libraries(zeek_fuzzer_shared
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
add_fuzz_target(pop3)
add_fuzz_target(packet)

Binary file not shown.

View file

@ -0,0 +1,45 @@
#include "binpac.h"
#include "iosource/Packet.h"
#include "Event.h"
#include "Sessions.h"
#include "FuzzBuffer.h"
#include "fuzzer-setup.h"
#include "pcap/dlt.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
zeek::detail::FuzzBuffer fb{data, size};
if ( ! fb.Valid() )
return 0;
for ( ; ; )
{
auto chunk = fb.Next();
if ( ! chunk )
break;
Packet pkt;
auto timestamp = 42;
pkt_timeval ts = {timestamp, 0};
pkt.Init(DLT_RAW, &ts, chunk->size, chunk->size, chunk->data.get(), false, "");
try
{
sessions->NextPacket(timestamp, &pkt);
}
catch ( binpac::Exception const &e )
{
}
chunk = {};
mgr.Drain();
}
zeek::detail::fuzzer_cleanup_one_input();
return 0;
}