diff options
author | teor (Tim Wilson-Brown) <teor2345@gmail.com> | 2015-11-23 08:46:26 +1100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-11-25 22:26:10 -0500 |
commit | e14f9dd44f637c0211530e5e630eba1a129d1650 (patch) | |
tree | 200b515f20004c01f7e9df49d115e70d48f095df | |
parent | 289b184e112885d4feb9569c77d322995b9417c7 (diff) | |
download | tor-e14f9dd44f637c0211530e5e630eba1a129d1650.tar.gz tor-e14f9dd44f637c0211530e5e630eba1a129d1650.zip |
fixup! Add controller getinfo exit-policy/reject-private
Stop ignoring ExitPolicyRejectPrivate in getinfo
exit-policy/reject-private. Fix a memory leak.
Set ExitPolicyRejectPrivate in the unit tests, and make a mock
function declaration static.
-rw-r--r-- | src/or/policies.c | 11 | ||||
-rw-r--r-- | src/test/test_policy.c | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/or/policies.c b/src/or/policies.c index 4d9b17cc32..ec11375636 100644 --- a/src/or/policies.c +++ b/src/or/policies.c @@ -2140,14 +2140,20 @@ getinfo_helper_policies(control_connection_t *conn, } else if (!strcmp(question, "exit-policy/reject-private/relay")) { const or_options_t *options = get_options(); const routerinfo_t *me = router_get_my_routerinfo(); - smartlist_t *private_policy_list = smartlist_new(); - smartlist_t *configured_addresses = smartlist_new(); if (!me) { *errmsg = "router_get_my_routerinfo returned NULL"; return -1; } + if (!options->ExitPolicyRejectPrivate) { + *answer = tor_strdup(""); + return 0; + } + + smartlist_t *private_policy_list = smartlist_new(); + smartlist_t *configured_addresses = smartlist_new(); + /* Add the configured addresses to the tor_addr_t* list */ policies_add_ipv4h_to_smartlist(configured_addresses, me->addr); policies_add_addr_to_smartlist(configured_addresses, &me->ipv6_addr); @@ -2162,6 +2168,7 @@ getinfo_helper_policies(control_connection_t *conn, *answer = policy_dump_to_string(private_policy_list, 1, 1); addr_policy_list_free(private_policy_list); + addr_policy_list_free(configured_addresses); } else if (!strcmpstart(question, "exit-policy/")) { const routerinfo_t *me = router_get_my_routerinfo(); diff --git a/src/test/test_policy.c b/src/test/test_policy.c index 63672ea6cd..082f930551 100644 --- a/src/test/test_policy.c +++ b/src/test/test_policy.c @@ -994,6 +994,7 @@ test_policies_getinfo_helper_policies(void *arg) append_exit_policy_string(&mock_my_routerinfo.exit_policy, "reject *6:*"); mock_options.IPv6Exit = 1; + mock_options.ExitPolicyRejectPrivate = 1; tor_addr_from_ipv4h(&mock_options.OutboundBindAddressIPv4_, TEST_IPV4_ADDR); tor_addr_parse(&mock_options.OutboundBindAddressIPv6_, TEST_IPV6_ADDR); |