summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2010-04-03 12:13:25 +0200
committerSebastian Hahn <sebastian@torproject.org>2010-04-03 12:31:59 +0200
commit80d9737e705242891b24cc765cbbdc72187a34de (patch)
tree78fd2c0e43c351ed989cc298d14863093e7a8509
parent51d084f8055265fe9a97236f7f3777ec160ba27b (diff)
downloadtor-80d9737e705242891b24cc765cbbdc72187a34de.tar.gz
tor-80d9737e705242891b24cc765cbbdc72187a34de.zip
Fix a segfault when a client is hup'd.
We need to make sure we have an event_base in dns.c before we call anything that wants one. Make sure we always have one in dns_reset() when we're a client. Fixes bug 1341.
-rw-r--r--changes/dont_segfault_client_on_hup3
-rw-r--r--src/or/dns.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/changes/dont_segfault_client_on_hup b/changes/dont_segfault_client_on_hup
new file mode 100644
index 0000000000..96ffeb710f
--- /dev/null
+++ b/changes/dont_segfault_client_on_hup
@@ -0,0 +1,3 @@
+ o Major bugfixes:
+ - Fix a segfault that happens whenever a Tor client is hup'd. Bugfix
+ on 0.2.2.5-alpha; fixes bug 1341.
diff --git a/src/or/dns.c b/src/or/dns.c
index 54acef4be2..192a1929d7 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -260,6 +260,14 @@ dns_reset(void)
{
or_options_t *options = get_options();
if (! server_mode(options)) {
+
+ if (!the_evdns_base) {
+ if (!(the_evdns_base = evdns_base_new(tor_libevent_get_base(), 0))) {
+ log_err(LD_BUG, "Couldn't create an evdns_base");
+ return -1;
+ }
+ }
+
evdns_base_clear_nameservers_and_suspend(the_evdns_base);
evdns_base_search_clear(the_evdns_base);
nameservers_configured = 0;
@@ -1377,6 +1385,8 @@ launch_resolve(edge_connection_t *exitconn)
r = tor_addr_parse_reverse_lookup_name(
&a, exitconn->_base.address, AF_UNSPEC, 0);
+
+ tor_assert(the_evdns_base);
if (r == 0) {
log_info(LD_EXIT, "Launching eventdns request for %s",
escaped_safe_str(exitconn->_base.address));
@@ -1546,6 +1556,7 @@ launch_wildcard_check(int min_len, int max_len, const char *suffix)
log_info(LD_EXIT, "Testing whether our DNS server is hijacking nonexistent "
"domains with request for bogus hostname \"%s\"", addr);
+ tor_assert(the_evdns_base);
req = evdns_base_resolve_ipv4(
the_evdns_base,
/* This "addr" tells us which address to resolve */
@@ -1576,6 +1587,7 @@ launch_test_addresses(int fd, short event, void *args)
* be an exit server.*/
if (!options->ServerDNSTestAddresses)
return;
+ tor_assert(the_evdns_base);
SMARTLIST_FOREACH_BEGIN(options->ServerDNSTestAddresses,
const char *, address) {
char *a = tor_strdup(address);