fuzz_socks.c 937 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Copyright (c) 2016-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #include "orconfig.h"
  4. #define BUFFERS_PRIVATE
  5. #include "core/or/or.h"
  6. #include "lib/container/buffers.h"
  7. #include "lib/err/backtrace.h"
  8. #include "lib/log/log.h"
  9. #include "core/proto/proto_socks.h"
  10. #include "feature/client/addressmap.h"
  11. #include "test/fuzz/fuzzing.h"
  12. int
  13. fuzz_init(void)
  14. {
  15. addressmap_init();
  16. return 0;
  17. }
  18. int
  19. fuzz_cleanup(void)
  20. {
  21. addressmap_free_all();
  22. return 0;
  23. }
  24. int
  25. fuzz_main(const uint8_t *stdin_buf, size_t data_size)
  26. {
  27. buf_t *buffer = buf_new_with_data((char*)stdin_buf, data_size);
  28. if (!buffer) {
  29. tor_assert(data_size==0);
  30. buffer = buf_new();
  31. }
  32. socks_request_t *request = socks_request_new();
  33. int r = fetch_from_buf_socks(buffer, request, 0, 0);
  34. log_info(LD_GENERAL, "Socks request status: %d", r);
  35. /* Reset. */
  36. buf_free(buffer);
  37. socks_request_free(request);
  38. return 0;
  39. }