• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/mdnsd/tests/fuzz/test-fuzz.c

  1 #define _GNU_SOURCE
  2 #include <stdio.h>
  3 #include <stdint.h>
  4 #include <stdlib.h>
  5 #include <stddef.h>
  6 #include <string.h>
  7 #include <fcntl.h>
  8 #include <errno.h>
  9 #include <unistd.h>
 10 
 11 #include <sys/types.h>
 12 #include <sys/stat.h>
 13 
 14 #include "dns.h"
 15 #include "cache.c"
 16 #include "interface.h"
 17 
 18 int cfg_proto = 0;
 19 int cfg_no_subnet = 0;
 20 
 21 static void fuzz_dns_handle_packet(uint8_t *input, size_t size)
 22 {
 23         struct sockaddr from;
 24         struct interface iface;
 25         struct cache_service *s, *t;
 26 
 27         memset(&from, 0, sizeof(from));
 28         memset(&iface, 0, sizeof(iface));
 29 
 30         cache_init();
 31         dns_handle_packet(&iface, &from, 1922, input, size);
 32 
 33         avl_for_each_element_safe(&services, s, avl, t)
 34                 cache_service_free(s);
 35 }
 36 
 37 int LLVMFuzzerTestOneInput(const uint8_t *input, size_t size)
 38 {
 39         uint8_t *buf = calloc(1, size);
 40         if (!buf)
 41                 return 0;
 42 
 43         memcpy(buf, input, size);
 44         fuzz_dns_handle_packet(buf, size);
 45         free(buf);
 46 
 47         return 0;
 48 }
 49 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt