[tor-commits] [tor/release-0.4.4] Make config/parse_tcp_proxy_line work in the presence of DNS hijacking

ahf at torproject.org ahf at torproject.org
Thu Nov 19 17:44:36 UTC 2020


commit 4154158d79452a5026c25750fae220a529c00fa3
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Nov 5 09:47:32 2020 -0500

    Make config/parse_tcp_proxy_line work in the presence of DNS hijacking
    
    We can use our existing mocking functionality to do this: We have
    been in this position before.
    
    Fixes part of #40179; bugfix on 0.4.3.1-alpha.
---
 changes/bug40179_part2 | 4 ++++
 src/test/test_config.c | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/changes/bug40179_part2 b/changes/bug40179_part2
new file mode 100644
index 0000000000..15dc861321
--- /dev/null
+++ b/changes/bug40179_part2
@@ -0,0 +1,4 @@
+  o Minor bugfixes (testing):
+    - Fix the config/parse_tcp_proxy_line test so that it works correctly on
+      systems where the DNS provider hijacks invalid queries.
+      Fixes part of bug 40179; bugfix on 0.4.3.1-alpha.
diff --git a/src/test/test_config.c b/src/test/test_config.c
index ae3f04de11..8ea744d4fd 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -703,11 +703,13 @@ test_config_parse_tcp_proxy_line(void *arg)
   tor_free(msg);
 
   /* Bad TCPProxy line - unparsable address/port. */
-  ret = parse_tcp_proxy_line("haproxy 95.216.163.36/443", options, &msg);
+  MOCK(tor_addr_lookup, mock_tor_addr_lookup__fail_on_bad_addrs);
+  ret = parse_tcp_proxy_line("haproxy bogus_address!/300", options, &msg);
   tt_int_op(ret, OP_EQ, -1);
   tt_str_op(msg, OP_EQ, "TCPProxy address/port failed to parse or resolve. "
                         "Please fix.");
   tor_free(msg);
+  UNMOCK(tor_addr_lookup);
 
   /* Good TCPProxy line - ipv4. */
   ret = parse_tcp_proxy_line("haproxy 95.216.163.36:443", options, &msg);
@@ -720,7 +722,7 @@ test_config_parse_tcp_proxy_line(void *arg)
   tor_free(msg);
 
  done:
-  ;
+  UNMOCK(tor_addr_lookup);
 }
 
 /**





More information about the tor-commits mailing list