1 #include <stdint.h> 2 #include <string.h> 3 4 extern "C" { 5 #include <avahi-common/malloc.h> 6 #include <avahi-core/dns.h> 7 #include <avahi-core/log.h> 8 } 9 log_function(AvahiLogLevel level,const char * txt)10void log_function(AvahiLogLevel level, const char *txt) {} 11 12 struct AvahiState { AvahiStateAvahiState13 AvahiState() { 14 avahi_set_log_function(log_function); 15 } 16 }; 17 18 AvahiState kGlobalSate; 19 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)20extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 21 AvahiDnsPacket* packet = avahi_dns_packet_new(size + AVAHI_DNS_PACKET_EXTRA_SIZE); 22 memcpy(AVAHI_DNS_PACKET_DATA(packet), data, size); 23 packet->size = size; 24 AvahiKey* key = avahi_dns_packet_consume_key(packet, nullptr); 25 if (key) { 26 avahi_key_is_valid(key); 27 char *s = avahi_key_to_string(key); 28 avahi_free(s); 29 avahi_key_unref(key); 30 } 31 avahi_dns_packet_free(packet); 32 33 return 0; 34 }