ares-test-fuzz-name.c 602 B

1234567891011121314151617181920212223
  1. #include <stddef.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "ares.h"
  5. // Include ares internal file for DNS protocol constants
  6. #include "ares_nameser.h"
  7. // Entrypoint for Clang's libfuzzer, exercising query creation.
  8. int LLVMFuzzerTestOneInput(const unsigned char *data,
  9. unsigned long size) {
  10. // Null terminate the data.
  11. char *name = malloc(size + 1);
  12. name[size] = '\0';
  13. memcpy(name, data, size);
  14. unsigned char *buf = NULL;
  15. int buflen = 0;
  16. ares_create_query(name, C_IN, T_AAAA, 1234, 0, &buf, &buflen, 1024);
  17. free(buf);
  18. free(name);
  19. return 0;
  20. }