summaryrefslogtreecommitdiff
path: root/src/test/fuzz/fuzzing_common.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-12-14 08:05:22 -0500
committerNick Mathewson <nickm@torproject.org>2017-01-30 08:37:23 -0500
commit56b61d18311998210f07c3d4b4f21a497bc04d48 (patch)
tree4156ce07549916e3f9ebe963d9c737415c31a40f /src/test/fuzz/fuzzing_common.c
parent584d723e04751330a677e7ce3673fc665713ea0a (diff)
downloadtor-56b61d18311998210f07c3d4b4f21a497bc04d48.tar.gz
tor-56b61d18311998210f07c3d4b4f21a497bc04d48.zip
Add more tweaks from teor's http fuzzing code.
Move option-manipulation code to fuzzing_common.
Diffstat (limited to 'src/test/fuzz/fuzzing_common.c')
-rw-r--r--src/test/fuzz/fuzzing_common.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/fuzz/fuzzing_common.c b/src/test/fuzz/fuzzing_common.c
index f2570a1a12..54a792353d 100644
--- a/src/test/fuzz/fuzzing_common.c
+++ b/src/test/fuzz/fuzzing_common.c
@@ -10,6 +10,13 @@
extern const char tor_git_revision[];
const char tor_git_revision[] = "";
+static or_options_t *mock_options = NULL;
+static const or_options_t *
+mock_get_options(void)
+{
+ return mock_options;
+}
+
static int
mock_crypto_pk_public_checksig__nocheck(const crypto_pk_t *env, char *to,
size_t tolen,
@@ -116,6 +123,10 @@ main(int argc, char **argv)
init_logging(1);
configure_backtrace_handler(get_version());
+ /* set up the options. */
+ mock_options = tor_malloc(sizeof(or_options_t));
+ MOCK(get_options, mock_get_options);
+
for (int i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "--warn")) {
loglevel = LOG_WARN;
@@ -156,6 +167,9 @@ main(int argc, char **argv)
if (fuzz_cleanup() < 0)
abort();
+
+ tor_free(mock_options);
+ UNMOCK(get_options);
return 0;
}