fuzz_target_dnsdistcache) ;
- MOADNSParser (fuzz_target_moadnsparser) ;
- the Proxy Protocol parser (fuzz_target_proxyprotocol) ;
+- the HTTP parser we use (YaHTTP, fuzz_target_yahttp) ;
- ZoneParserTNG (fuzz_target_zoneparsertng).
- Parts of the ragel-generated parser (parseRFC1035CharString in
fuzz_target_dnslabeltext)
of the PowerDNS products.
The 'corpus' directory contains three sub-directories:
+- http-raw-payloads/ contains HTTP payloads of queries, used by
+ fuzz_target_yahttp ;
- proxy-protocol-raw-packets/ contains DNS queries prefixed with a Proxy
Protocol v2 header, used by fuzz_target_proxyprotocol ;
- raw-dns-packets/ contains DNS queries and responses as captured on
--- /dev/null
+GET / HTTP/1.0
+
--- /dev/null
+GET /foo?param=42a HTTP/1.1
+Host: 127.0.0.1:8085
+User-Agent: HTTPie/2.3.0
+Accept-Encoding: gzip, deflate
+Accept: */*
+Connection: keep-alive
+X-API-Key: redacted
+customheader: foobar
+Authorization: Basic YTpzdXBlcnNlY3JldA==
+
--- /dev/null
+PUT /api/v1/servers/localhost/config/allow-from HTTP/1.1
+Host: 127.0.0.1:8085
+User-Agent: HTTPie/2.3.0
+Accept-Encoding: gzip, deflate
+Accept: application/json, */*;q=0.5
+Connection: keep-alive
+Content-Type: application/json
+X-API-Key: apikey
+Content-Length: 114
+
+{"name": "allow-from",
+ "type": "ConfigSetting",
+ "value": ["192.0.2.0/24", "198.51.100.0/24", "203.0.113.0/24"]}
/fuzz_target_moadnsparser
/fuzz_target_packetcache
/fuzz_target_proxyprotocol
+/fuzz_target_yahttp
/fuzz_target_zoneparsertng
/fuzz_target_dnslabeltext_parseRFC1035CharString
/.cache
fuzz_target_moadnsparser \
fuzz_target_packetcache \
fuzz_target_proxyprotocol \
- fuzz_target_zoneparsertng \
- fuzz_target_dnslabeltext_parseRFC1035CharString
+ fuzz_target_dnslabeltext_parseRFC1035CharString \
+ fuzz_target_yahttp \
+ fuzz_target_zoneparsertng
fuzz_targets: $(fuzz_targets_programs)
fuzz_target_dnsdistcache_LDFLAGS = $(fuzz_targets_ldflags)
fuzz_target_dnsdistcache_LDADD = $(fuzz_targets_libs)
+fuzz_target_yahttp_SOURCES = \
+ fuzz_yahttp.cc
+
+fuzz_target_yahttp_DEPENDENCIES = $(fuzz_targets_deps)
+fuzz_target_yahttp_LDFLAGS = $(fuzz_targets_ldflags)
+fuzz_target_yahttp_LDADD = $(fuzz_targets_libs) \
+ $(YAHTTP_LIBS)
+
fuzz_target_zoneparsertng_SOURCES = \
base32.cc base32.hh \
base64.cc base64.hh \
--- /dev/null
+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <yahttp/yahttp.hpp>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ try {
+ YaHTTP::AsyncRequestLoader yarl;
+ YaHTTP::Request req;
+
+ yarl.initialize(&req);
+ bool finished = yarl.feed(std::string(reinterpret_cast<const char*>(data), size));
+ if (finished) {
+ yarl.finalize();
+ }
+ }
+ catch (const YaHTTP::ParseError& e) {
+ }
+ catch (const std::exception& e) {
+ }
+ catch (...) {
+ }
+
+ return 0;
+}