diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2019-12-09 10:47:49 -0500 |
---|---|---|
committer | jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> | 2019-12-09 07:47:49 -0800 |
commit | b2603f7bc25107933019cca4578c566add8bceb8 (patch) | |
tree | d0b320d3c66a68db7f2c5322c5c4e6fb15b80193 /projects/avahi/avahi_packet_consume_key_fuzzer.cc | |
parent | f2410ec0b29feaac4f0db86466be5aa049e1ee01 (diff) |
Fuzzer for avahi's core DNS parser (#3098)
Diffstat (limited to 'projects/avahi/avahi_packet_consume_key_fuzzer.cc')
-rw-r--r-- | projects/avahi/avahi_packet_consume_key_fuzzer.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/projects/avahi/avahi_packet_consume_key_fuzzer.cc b/projects/avahi/avahi_packet_consume_key_fuzzer.cc new file mode 100644 index 00000000..cb631fd0 --- /dev/null +++ b/projects/avahi/avahi_packet_consume_key_fuzzer.cc @@ -0,0 +1,34 @@ +#include <stdint.h> +#include <string.h> + +extern "C" { +#include <avahi-common/malloc.h> +#include <avahi-core/dns.h> +#include <avahi-core/log.h> +} + +void log_function(AvahiLogLevel level, const char *txt) {} + +struct AvahiState { + AvahiState() { + avahi_set_log_function(log_function); + } +}; + +AvahiState kGlobalSate; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + AvahiDnsPacket* packet = avahi_dns_packet_new(size + AVAHI_DNS_PACKET_EXTRA_SIZE); + memcpy(AVAHI_DNS_PACKET_DATA(packet), data, size); + packet->size = size; + AvahiKey* key = avahi_dns_packet_consume_key(packet, nullptr); + if (key) { + avahi_key_is_valid(key); + char *s = avahi_key_to_string(key); + avahi_free(s); + avahi_key_unref(key); + } + avahi_dns_packet_free(packet); + + return 0; +}
\ No newline at end of file |