fuzz_iptsv2.c 1.0 KB

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