diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-01-03 10:11:23 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-01-03 10:17:00 -0500 |
commit | c4a6b56cc19878de4c76e83ce8e38ad709839d92 (patch) | |
tree | 8dcacd5e9b1bf64e412410fe22321ae0b2753756 /src/test/test_options.c | |
parent | f23ec14d62f82ee424b7aef9ff1c2253c3dd2b10 (diff) | |
download | tor-c4a6b56cc19878de4c76e83ce8e38ad709839d92.tar.gz tor-c4a6b56cc19878de4c76e83ce8e38ad709839d92.zip |
Fix unit test failures in response to DNS hijacking.
Some DNS NXDOMAIN hijackers hijack truly ridiculous domains, like
"invalid-stuff!!" or "1.2.3.4.5". This would provoke unit test
failures where we used addresses like that to force
tor_addr_lookup() to fail. The fix, for testing, is to mock
tor_addr_lookup() with a variant that always fails when it gets
a name with a !.
Fixes bugs 20862 and 20863.
Diffstat (limited to 'src/test/test_options.c')
-rw-r--r-- | src/test/test_options.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/test/test_options.c b/src/test/test_options.c index e85e11805b..3fe0dc33b0 100644 --- a/src/test/test_options.c +++ b/src/test/test_options.c @@ -18,6 +18,7 @@ #include "sandbox.h" #include "memarea.h" #include "policies.h" +#include "test_helpers.h" #define NS_MODULE test_options @@ -648,18 +649,21 @@ test_options_validate__authdir(void *ignored) int ret; char *msg; setup_capture_of_logs(LOG_INFO); + // XXXX But it _can_ exist, if you're DNS-hijacked. options_test_data_t *tdata = get_options_test_data( "AuthoritativeDirectory 1\n" - "Address this.should.not_exist.example.org"); + "Address this.should.not!exist!.example.org"); sandbox_disable_getaddrinfo_cache(); + MOCK(tor_addr_lookup, mock_tor_addr_lookup__fail_on_bad_addrs); ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg); + UNMOCK(tor_addr_lookup); tt_int_op(ret, OP_EQ, -1); tt_str_op(msg, OP_EQ, "Failed to resolve/guess local address. See logs for" " details."); expect_log_msg("Could not resolve local Address " - "'this.should.not_exist.example.org'. Failing.\n"); + "'this.should.not!exist!.example.org'. Failing.\n"); tor_free(msg); free_options_test_data(tdata); @@ -3037,6 +3041,7 @@ test_options_validate__proxy(void *ignored) options_test_data_t *tdata = NULL; sandbox_disable_getaddrinfo_cache(); setup_capture_of_logs(LOG_WARN); + MOCK(tor_addr_lookup, mock_tor_addr_lookup__fail_on_bad_addrs); free_options_test_data(tdata); tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES @@ -3057,6 +3062,7 @@ test_options_validate__proxy(void *ignored) tor_free(msg); free_options_test_data(tdata); + tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES "HttpProxy not_so_valid!\n" ); @@ -3357,6 +3363,7 @@ test_options_validate__proxy(void *ignored) policies_free_all(); // sandbox_free_getaddrinfo_cache(); tor_free(msg); + UNMOCK(tor_addr_lookup); } static void |