fuzz_iptsv2.c 902 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (c) 2016-2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #define ROUTERPARSE_PRIVATE
  4. #include "or.h"
  5. #include "routerparse.h"
  6. #include "rendcommon.h"
  7. #include "fuzzing.h"
  8. static void
  9. mock_dump_desc__nodump(const char *desc, const char *type)
  10. {
  11. (void)desc;
  12. (void)type;
  13. }
  14. int
  15. fuzz_init(void)
  16. {
  17. disable_signature_checking();
  18. MOCK(dump_desc, mock_dump_desc__nodump);
  19. ed25519_init();
  20. return 0;
  21. }
  22. int
  23. fuzz_cleanup(void)
  24. {
  25. return 0;
  26. }
  27. int
  28. fuzz_main(const uint8_t *data, size_t sz)
  29. {
  30. rend_service_descriptor_t *desc =
  31. tor_malloc_zero(sizeof(rend_service_descriptor_t));
  32. const char *str = (const char*) data;
  33. int r = rend_parse_introduction_points(desc, str, sz);
  34. if (r >= 0) {
  35. log_debug(LD_GENERAL, "Parsing okay: %d", r);
  36. } else {
  37. log_debug(LD_GENERAL, "Parsing failed");
  38. }
  39. rend_service_descriptor_free(desc);
  40. return 0;
  41. }