From e8ffb27d63cc7329b7b949e9e6fe738079e16ab3 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 27 Nov 2018 17:16:33 +0100 Subject: [PATCH] fuzzing: Skip payloads larger than 65k --- pdns/fuzz_dnsdistcache.cc | 4 ++++ pdns/fuzz_moadnsparser.cc | 4 ++++ pdns/fuzz_packetcache.cc | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/pdns/fuzz_dnsdistcache.cc b/pdns/fuzz_dnsdistcache.cc index d9c8efa71..8b2ed7d1f 100644 --- a/pdns/fuzz_dnsdistcache.cc +++ b/pdns/fuzz_dnsdistcache.cc @@ -24,6 +24,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + if (size > std::numeric_limits::max()) { + return 0; + } + /* dnsdist's version */ try { uint16_t qtype; diff --git a/pdns/fuzz_moadnsparser.cc b/pdns/fuzz_moadnsparser.cc index cf9660ec7..ea5fe25e9 100644 --- a/pdns/fuzz_moadnsparser.cc +++ b/pdns/fuzz_moadnsparser.cc @@ -39,6 +39,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { initialized = true; } + if (size > std::numeric_limits::max()) { + return 0; + } + try { MOADNSParser moaQuery(true, reinterpret_cast(data), size); } diff --git a/pdns/fuzz_packetcache.cc b/pdns/fuzz_packetcache.cc index b8d9f2261..faea01692 100644 --- a/pdns/fuzz_packetcache.cc +++ b/pdns/fuzz_packetcache.cc @@ -27,6 +27,10 @@ StatBag S; extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + if (size > std::numeric_limits::max()) { + return 0; + } + std::string input(reinterpret_cast(data), size); /* auth's version */ -- 2.40.0