From c68240b14959e5660abef699320233710752013a Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 16 Aug 2023 16:44:37 +0200 Subject: [PATCH] Format fuzzing targets --- .not-formatted | 5 ----- pdns/dnsdistdist/fuzz_dnsdistcache.cc | 9 +++++---- pdns/fuzz_moadnsparser.cc | 11 ++++++----- pdns/fuzz_packetcache.cc | 15 ++++++++------- pdns/fuzz_proxyprotocol.cc | 9 +++++---- pdns/fuzz_zoneparsertng.cc | 7 ++++--- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.not-formatted b/.not-formatted index e48e5f4affe6..c4d86e3d2964 100644 --- a/.not-formatted +++ b/.not-formatted @@ -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 diff --git a/pdns/dnsdistdist/fuzz_dnsdistcache.cc b/pdns/dnsdistdist/fuzz_dnsdistcache.cc index c224449533e0..6c10920d4a9a 100644 --- a/pdns/dnsdistdist/fuzz_dnsdistcache.cc +++ b/pdns/dnsdistdist/fuzz_dnsdistcache.cc @@ -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::max()) { return 0; @@ -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(data), size, sizeof(dnsheader), false, &qtype, &qclass, &consumed); pcSkipCookies.getKey(qname.getStorage(), consumed, vect, false); pcHashCookies.getKey(qname.getStorage(), consumed, vect, false); boost::optional 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; diff --git a/pdns/fuzz_moadnsparser.cc b/pdns/fuzz_moadnsparser.cc index 2605ea82047e..afb3bdea4598 100644 --- a/pdns/fuzz_moadnsparser.cc +++ b/pdns/fuzz_moadnsparser.cc @@ -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) { @@ -48,17 +49,17 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { try { MOADNSParser moaQuery(true, reinterpret_cast(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(data), size); } - catch(const std::exception& e) { + catch (const std::exception& e) { } - catch(const PDNSException& e) { + catch (const PDNSException& e) { } return 0; diff --git a/pdns/fuzz_packetcache.cc b/pdns/fuzz_packetcache.cc index 0c982d0e72ac..d607586d53b3 100644 --- a/pdns/fuzz_packetcache.cc +++ b/pdns/fuzz_packetcache.cc @@ -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::max() || size < sizeof(dnsheader)) { return 0; @@ -37,28 +38,28 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* auth's version */ try { - static const std::unordered_set optionsToIgnore{ EDNSOptionCode::COOKIE }; + static const std::unordered_set 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 optionsToIgnore{ EDNSOptionCode::COOKIE, EDNSOptionCode::ECS }; + static const std::unordered_set 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; diff --git a/pdns/fuzz_proxyprotocol.cc b/pdns/fuzz_proxyprotocol.cc index 25885c8883d0..f9ec613ef33d 100644 --- a/pdns/fuzz_proxyprotocol.cc +++ b/pdns/fuzz_proxyprotocol.cc @@ -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 values; ComboAddress source; ComboAddress destination; bool proxy = false; - bool tcp = false; + bool tcp = false; try { parseProxyHeader(std::string(reinterpret_cast(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; diff --git a/pdns/fuzz_zoneparsertng.cc b/pdns/fuzz_zoneparsertng.cc index 98e0d5ce383c..03c4ca55d092 100644 --- a/pdns/fuzz_zoneparsertng.cc +++ b/pdns/fuzz_zoneparsertng.cc @@ -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) { @@ -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;