Skip to content

Commit

Permalink
Format fuzzing targets
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Aug 16, 2023
1 parent cabda03 commit c68240b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
5 changes: 0 additions & 5 deletions .not-formatted
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@
./pdns/ednssubnet.hh
./pdns/fstrm_logger.cc
./pdns/fstrm_logger.hh
./pdns/fuzz_dnsdistcache.cc
./pdns/fuzz_moadnsparser.cc
./pdns/fuzz_packetcache.cc
./pdns/fuzz_proxyprotocol.cc
./pdns/fuzz_zoneparsertng.cc
./pdns/gettime.cc
./pdns/gettime.hh
./pdns/histog.hh
Expand Down
9 changes: 5 additions & 4 deletions pdns/dnsdistdist/fuzz_dnsdistcache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{

if (size > std::numeric_limits<uint16_t>::max()) {
return 0;
Expand All @@ -44,16 +45,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
uint16_t qtype;
uint16_t qclass;
unsigned int consumed;
PacketBuffer vect(data, data+size);
PacketBuffer vect(data, data + size);
const DNSName qname(reinterpret_cast<const char*>(data), size, sizeof(dnsheader), false, &qtype, &qclass, &consumed);
pcSkipCookies.getKey(qname.getStorage(), consumed, vect, false);
pcHashCookies.getKey(qname.getStorage(), consumed, vect, false);
boost::optional<Netmask> subnet;
DNSDistPacketCache::getClientSubnet(vect, consumed, subnet);
}
catch(const std::exception& e) {
catch (const std::exception& e) {
}
catch(const PDNSException& e) {
catch (const PDNSException& e) {
}

return 0;
Expand Down
11 changes: 6 additions & 5 deletions pdns/fuzz_moadnsparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ static void init()

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
static bool initialized = false;

if (!initialized) {
Expand All @@ -48,17 +49,17 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
try {
MOADNSParser moaQuery(true, reinterpret_cast<const char*>(data), size);
}
catch(const std::exception& e) {
catch (const std::exception& e) {
}
catch(const PDNSException& e) {
catch (const PDNSException& e) {
}

try {
MOADNSParser moaAnswer(false, reinterpret_cast<const char*>(data), size);
}
catch(const std::exception& e) {
catch (const std::exception& e) {
}
catch(const PDNSException& e) {
catch (const PDNSException& e) {
}

return 0;
Expand Down
15 changes: 8 additions & 7 deletions pdns/fuzz_packetcache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ StatBag S;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{

if (size > std::numeric_limits<uint16_t>::max() || size < sizeof(dnsheader)) {
return 0;
Expand All @@ -37,28 +38,28 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {

/* auth's version */
try {
static const std::unordered_set<uint16_t> optionsToIgnore{ EDNSOptionCode::COOKIE };
static const std::unordered_set<uint16_t> optionsToIgnore{EDNSOptionCode::COOKIE};

PacketCache::canHashPacket(input, optionsToIgnore);
DNSName qname(input.data(), input.size(), sizeof(dnsheader), false);
PacketCache::queryMatches(input, input, qname, optionsToIgnore);
}
catch(const std::exception& e) {
catch (const std::exception& e) {
}
catch(const PDNSException& e) {
catch (const PDNSException& e) {
}

/* recursor's version */
try {
static const std::unordered_set<uint16_t> optionsToIgnore{ EDNSOptionCode::COOKIE, EDNSOptionCode::ECS };
static const std::unordered_set<uint16_t> optionsToIgnore{EDNSOptionCode::COOKIE, EDNSOptionCode::ECS};

PacketCache::canHashPacket(input, optionsToIgnore);
DNSName qname(input.data(), input.size(), sizeof(dnsheader), false);
PacketCache::queryMatches(input, input, qname, optionsToIgnore);
}
catch(const std::exception& e) {
catch (const std::exception& e) {
}
catch(const PDNSException& e) {
catch (const PDNSException& e) {
}

return 0;
Expand Down
9 changes: 5 additions & 4 deletions pdns/fuzz_proxyprotocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{

std::vector<ProxyProtocolValue> values;
ComboAddress source;
ComboAddress destination;
bool proxy = false;
bool tcp = false;
bool tcp = false;

try {
parseProxyHeader(std::string(reinterpret_cast<const char*>(data), size), proxy, source, destination, tcp, values);
}
catch(const std::exception& e) {
catch (const std::exception& e) {
}
catch(const PDNSException& e) {
catch (const PDNSException& e) {
}

return 0;
Expand Down
7 changes: 4 additions & 3 deletions pdns/fuzz_zoneparsertng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ static void init()

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
static bool initialized = false;

if (!initialized) {
Expand All @@ -56,9 +57,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
while (zpt.get(drr)) {
}
}
catch(const std::exception& e) {
catch (const std::exception& e) {
}
catch(const PDNSException& e) {
catch (const PDNSException& e) {
}

return 0;
Expand Down

0 comments on commit c68240b

Please sign in to comment.