- MOADNSParser (fuzz_target_moadnsparser) ;
- the Proxy Protocol parser (fuzz_target_proxyprotocol) ;
- ZoneParserTNG (fuzz_target_zoneparsertng).
+- Parts of the ragel-generated parser (parseRFC1035CharString in
+ fuzz_target_dnslabeltext)
By default the targets are linked against a standalone target,
pdns/standalone_fuzz_target_runner.cc, which does no fuzzing but makes it easy
When run in the OSS-Fuzz environment, the zone files from the
regression-tests/zones/ directory are added to the ones present
in the fuzzing/corpus/zones/ directory.
+
+Quickly getting started (using clang 11)
+----------------------------------------
+First, confgure:
+
+```
+LIB_FUZZING_ENGINE="/usr/lib/clang/11.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a" \
+ CC=clang \
+ CXX=clang++ \
+ CFLAGS='-fsanitize=fuzzer-no-link' \
+ CXXFLAGS='-fsanitize=fuzzer-no-link' \
+ ./configure --without-dynmodules --with-modules= --disable-lua-records --disable-ixfrdist --enable-fuzz-targets --disable-dependency-tracking --disable-silent-rules --enable-asan --enable-ubsan
+```
+
+Then build:
+
+```
+LIB_FUZZING_ENGINE="/usr/lib/clang/11.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a" \
+ make -C pdns -j2 fuzz_targets
+```
+
+Now you're ready to run one of the fuzzing targets.
+First, copy the starting corpus:
+
+```
+mkdir new-corpus
+./pdns/fuzz_target_XXXXXXX -merge=1 new-corpus fuzzing/corpus/YYYYY
+```
+
+Then run the thing:
+```
+./pdns_fuzz_target_XXXXXXX new-corpus
+```
+
+The [LLVM docs](https://llvm.org/docs/LibFuzzer.html) have more info.
--- /dev/null
+esc\033aped\!
--- /dev/null
+"esc\033ped!"
/fuzz_target_packetcache
/fuzz_target_proxyprotocol
/fuzz_target_zoneparsertng
+/fuzz_target_dnslabeltext_parseRFC1035CharString
fuzz_target_moadnsparser \
fuzz_target_packetcache \
fuzz_target_proxyprotocol \
- fuzz_target_zoneparsertng
+ fuzz_target_zoneparsertng \
+ fuzz_target_dnslabeltext_parseRFC1035CharString
fuzz_targets: $(fuzz_targets_programs)
fuzz_target_zoneparsertng_LDFLAGS = $(fuzz_targets_ldflags)
fuzz_target_zoneparsertng_LDADD = $(fuzz_targets_libs)
+fuzz_target_dnslabeltext_parseRFC1035CharString_SOURCES = \
+ dnslabeltext.cc \
+ fuzz_dnslabeltext_parseRFC1035CharString.cc
+
+fuzz_target_dnslabeltext_parseRFC1035CharString_DEPENDENCIES = $(fuzz_targets_deps)
+fuzz_target_dnslabeltext_parseRFC1035CharString_LDFLAGS = $(fuzz_targets_ldflags)
+fuzz_target_dnslabeltext_parseRFC1035CharString_LDADD = $(fuzz_targets_libs)
+
endif
dnslabeltext.cc: dnslabeltext.rl
--- /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 "misc.hh"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+
+ std::string val;
+
+ std::string input((char*)data, size);
+ parseRFC1035CharString(input, val);
+
+ return 0;
+}