fuzz_hsdescv2.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (c) 2016-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #include "core/or/or.h"
  4. #include "feature/dirparse/unparseable.h"
  5. #include "feature/rend/rendcommon.h"
  6. #include "feature/rend/rendparse.h"
  7. #include "lib/crypt_ops/crypto_ed25519.h"
  8. #include "test/fuzz/fuzzing.h"
  9. static void
  10. mock_dump_desc__nodump(const char *desc, const char *type)
  11. {
  12. (void)desc;
  13. (void)type;
  14. }
  15. int
  16. fuzz_init(void)
  17. {
  18. disable_signature_checking();
  19. MOCK(dump_desc, mock_dump_desc__nodump);
  20. ed25519_init();
  21. return 0;
  22. }
  23. int
  24. fuzz_cleanup(void)
  25. {
  26. return 0;
  27. }
  28. int
  29. fuzz_main(const uint8_t *data, size_t sz)
  30. {
  31. rend_service_descriptor_t *desc = NULL;
  32. char desc_id[64];
  33. char *ipts = NULL;
  34. size_t ipts_size, esize;
  35. const char *next;
  36. char *str = tor_memdup_nulterm(data, sz);
  37. (void) rend_parse_v2_service_descriptor(&desc, desc_id, &ipts, &ipts_size,
  38. &esize, &next, str, 1);
  39. if (desc) {
  40. log_debug(LD_GENERAL, "Parsing okay");
  41. rend_service_descriptor_free(desc);
  42. } else {
  43. log_debug(LD_GENERAL, "Parsing failed");
  44. }
  45. tor_free(ipts);
  46. tor_free(str);
  47. return 0;
  48. }