Merge branch 'maint-0.4.8'
[tor.git] / src / test / fuzz / fuzz_socks.c
blobeeb989994da841f0fddf1083f21dab1d1bebb1f2
1 /* Copyright (c) 2016-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #include "orconfig.h"
6 #define BUFFERS_PRIVATE
7 #include "core/or/or.h"
9 #include "lib/buf/buffers.h"
10 #include "lib/err/backtrace.h"
11 #include "lib/log/log.h"
12 #include "core/proto/proto_socks.h"
13 #include "feature/client/addressmap.h"
15 #include "test/fuzz/fuzzing.h"
17 int
18 fuzz_init(void)
20 addressmap_init();
21 return 0;
24 int
25 fuzz_cleanup(void)
27 addressmap_free_all();
28 return 0;
31 int
32 fuzz_main(const uint8_t *stdin_buf, size_t data_size)
34 buf_t *buffer = buf_new_with_data((char*)stdin_buf, data_size);
35 if (!buffer) {
36 tor_assert(data_size==0);
37 buffer = buf_new();
40 socks_request_t *request = socks_request_new();
42 int r = fetch_from_buf_socks(buffer, request, 0, 0);
43 log_info(LD_GENERAL, "Socks request status: %d", r);
45 /* Reset. */
46 buf_free(buffer);
47 socks_request_free(request);
49 return 0;