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

[or-cvs] r8225: Resolve bug 321 when using dnsworkers: append a period to ev (in tor/trunk: . src/or)



Author: nickm
Date: 2006-08-25 17:02:01 -0400 (Fri, 25 Aug 2006)
New Revision: 8225

Modified:
   tor/trunk/
   tor/trunk/src/or/dns.c
Log:
 r8573@Kushana:  nickm | 2006-08-25 16:55:19 -0400
 Resolve bug 321 when using dnsworkers: append a period to every address we resolve at the exit node, so that we do not accidentally pick up local addresses, and so that failing searches are retried in the resolver search domains.  (This is already solved for eventdns.)



Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
   - 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8290
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:8557
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:8572
   + 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8290
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:8557
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:8573

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2006-08-25 21:01:56 UTC (rev 8224)
+++ tor/trunk/src/or/dns.c	2006-08-25 21:02:01 UTC (rev 8225)
@@ -944,7 +944,7 @@
 static int
 dnsworker_main(void *data)
 {
-  char address[MAX_ADDRESSLEN];
+  char address[MAX_ADDRESSLEN+1]; /* Plus a byte for a final '.' */
   unsigned char address_len;
   char *log_address;
   char answer[5];
@@ -989,7 +989,13 @@
       crypto_thread_cleanup();
       spawn_exit();
     }
-    address[address_len] = 0; /* nul terminate it */
+    /* Add a period to prevent local domain search, and NUL-terminate. */
+    if (address[address_len-1] != '.') {
+      address[address_len] = '.';
+      address[address_len+1] = '\0';
+    } else {
+      address[address_len] = '\0';
+    }
 
     log_address = esc_for_log(safe_str(address));
     result = tor_lookup_hostname(address, &ip);
@@ -999,17 +1005,17 @@
     switch (result) {
       case 1:
         /* XXX result can never be 1, because we set it to -1 above on error */
-        log_info(LD_NET,"Could not resolve dest addr %s (transient).",
+        log_info(LD_NET,"Could not resolve dest addr %s (transient)",
                  log_address);
         answer[0] = DNS_RESOLVE_FAILED_TRANSIENT;
         break;
       case -1:
-        log_info(LD_NET,"Could not resolve dest addr %s (permanent).",
+        log_info(LD_NET,"Could not resolve dest addr %s (permanent)",
                  log_address);
         answer[0] = DNS_RESOLVE_FAILED_PERMANENT;
         break;
       case 0:
-        log_info(LD_NET,"Resolved address %s.", log_address);
+        log_info(LD_NET,"Resolved address %s", log_address);
         answer[0] = DNS_RESOLVE_SUCCEEDED;
         break;
     }