aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-01-03 10:11:23 -0500
committerNick Mathewson <nickm@torproject.org>2017-01-03 10:17:00 -0500
commitc4a6b56cc19878de4c76e83ce8e38ad709839d92 (patch)
tree8dcacd5e9b1bf64e412410fe22321ae0b2753756 /src/test/test_config.c
parentf23ec14d62f82ee424b7aef9ff1c2253c3dd2b10 (diff)
downloadtor-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_config.c')
-rw-r--r--src/test/test_config.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/test/test_config.c b/src/test/test_config.c
index a540bcc138..eeda34e089 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -46,6 +46,8 @@
#include "transports.h"
#include "util.h"
+#include "test_helpers.h"
+
static void
test_config_addressmap(void *arg)
{
@@ -4701,8 +4703,10 @@ test_config_parse_port_config__ports__ports_given(void *data)
// Test failure when asked to parse an invalid address followed by auto
config_free_lines(config_port_invalid); config_port_invalid = NULL;
config_port_invalid = mock_config_line("DNSPort", "invalidstuff!!:auto");
+ MOCK(tor_addr_lookup, mock_tor_addr_lookup__fail_on_bad_addrs);
ret = parse_port_config(NULL, config_port_invalid, NULL, "DNS", 0,
"127.0.0.46", 0, 0);
+ UNMOCK(tor_addr_lookup);
tt_int_op(ret, OP_EQ, -1);
// Test success with parsing both an address and a real port