[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9333: Fix a crash bug in the presence of DNS hijacking. (in tor/trunk: . src/or)



Author: nickm
Date: 2007-01-11 09:13:13 -0500 (Thu, 11 Jan 2007)
New Revision: 9333

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/dns.c
Log:
 r11931@Kushana:  nickm | 2007-01-11 09:12:49 -0500
 Fix a crash bug in the presence of DNS hijacking.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11931] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-01-11 14:13:04 UTC (rev 9332)
+++ tor/trunk/ChangeLog	2007-01-11 14:13:13 UTC (rev 9333)
@@ -1,4 +1,8 @@
 Changes in version 0.1.2.7-alpha - 2007-??-??
+ o Major bugfixes:
+    - Fix a crash bug in the presence of DNS hijacking  (reported by Andrew
+      Del Vecchio).
+
  o Minor bugfixes:
     - When computing clock skew from directory HTTP headers, consider what
       time it was when we finished asking for the directory, not what time it

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2007-01-11 14:13:04 UTC (rev 9332)
+++ tor/trunk/src/or/dns.c	2007-01-11 14:13:13 UTC (rev 9333)
@@ -1625,12 +1625,10 @@
       status = DNS_RESOLVE_FAILED_TRANSIENT;
   }
   if (was_wildcarded) {
-    int is_test_addr = is_test_address(hostname);
-
-    if (is_test_addr) {
+    if (is_test_address(string_address)) {
       /* Ick.  We're getting redirected on known-good addresses.  Our DNS
        * server must really hate us.  */
-      add_wildcarded_test_address(hostname);
+      add_wildcarded_test_address(string_address);
     }
   }
   if (result != DNS_ERR_SHUTDOWN)
@@ -1744,16 +1742,19 @@
 static void
 add_wildcarded_test_address(const char *address)
 {
-  int n;
+  int n, n_test_addrs;
   if (!dns_wildcarded_test_address_list)
     dns_wildcarded_test_address_list = smartlist_create();
 
   if (smartlist_string_isin_case(dns_wildcarded_test_address_list, address))
     return;
 
+  n_test_addrs = get_options()->ServerDNSTestAddresses ?
+    smartlist_len(get_options()->ServerDNSTestAddresses) : 0;
+
   smartlist_add(dns_wildcarded_test_address_list, tor_strdup(address));
   n = smartlist_len(dns_wildcarded_test_address_list);
-  if (n > smartlist_len(get_options()->ServerDNSTestAddresses)/2) {
+  if (n > n_test_addrs/2) {
     log(dns_wildcarded_test_address_notice_given ? LOG_INFO : LOG_NOTICE,
         LD_EXIT, "Your DNS provider tried to redirect \"%s\" to a junk "
         "address.  It has done this with %d test addresses so far.  I'm "