aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorpedbap <pedbap.g@gmail.com>2021-06-29 19:15:24 +0000
committerpedbap <pedbap.g@gmail.com>2021-06-29 19:15:24 +0000
commitad3519c165bd0fb18917068a4adc37f24fd84d80 (patch)
treeebb3640bcbca4d27ad29d1c6ed58abeb2cc3cfde /src/test
parent453ea20827d3628a203870cc885e7444e09b9f0d (diff)
downloadtor-ad3519c165bd0fb18917068a4adc37f24fd84d80.tar.gz
tor-ad3519c165bd0fb18917068a4adc37f24fd84d80.zip
tor_addr_parse_PTR_name() isolated harness
Diffstat (limited to 'src/test')
-rw-r--r--src/test/fuzz/fuzz_addressPTR.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/test/fuzz/fuzz_addressPTR.c b/src/test/fuzz/fuzz_addressPTR.c
new file mode 100644
index 0000000000..48894f1be8
--- /dev/null
+++ b/src/test/fuzz/fuzz_addressPTR.c
@@ -0,0 +1,71 @@
+#include "lib/net/address.h"
+#include "lib/net/socket.h"
+#include "lib/cc/ctassert.h"
+#include "lib/container/smartlist.h"
+#include "lib/ctime/di_ops.h"
+#include "lib/log/log.h"
+#include "lib/log/escape.h"
+#include "lib/malloc/malloc.h"
+#include "lib/net/inaddr.h"
+#include "lib/string/compat_ctype.h"
+#include "lib/string/compat_string.h"
+#include "lib/string/parse_int.h"
+#include "lib/string/printf.h"
+#include "lib/string/util_string.h"
+
+#include "ext/siphash.h"
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h> /* FreeBSD needs this to know what version it is */
+#endif
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+#ifdef HAVE_IFADDRS_H
+#include <ifaddrs.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int fuzz_init(void){
+ return 0;
+}
+
+int fuzz_cleanup(void){
+ return 0;
+}
+
+int fuzz_main(const uint8_t *data, size_t sz){
+
+ tor_addr_t addr_result;
+ char *fuzzing_data = tor_memdup_nulterm(data, sz);
+ tor_addr_parse_PTR_name(&addr_result, fuzzing_data, AF_UNSPEC, 1);
+ tor_free(fuzzing_data);
+ return 0;
+}