[or-cvs] When tor_lookup_hostname says 0.0.0.0, treat it as an error...

Nick Mathewson nickm at seul.org
Sun Jul 4 04:53:34 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv27833/src/or

Modified Files:
      Tag: tor-0_0_7-patches
	dns.c routerlist.c 
Log Message:
When tor_lookup_hostname says 0.0.0.0, treat it as an error. (Backport to 0.0.7 branch)

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.99
retrieving revision 1.99.2.1
diff -u -d -r1.99 -r1.99.2.1
--- dns.c	6 Jun 2004 03:38:31 -0000	1.99
+++ dns.c	4 Jul 2004 04:53:32 -0000	1.99.2.1
@@ -585,6 +585,7 @@
   uint32_t ip;
   int *fdarray = data;
   int fd;
+  int result;
 
   tor_close_socket(fdarray[0]); /* this is the side of the socketpair the parent uses */
   fd = fdarray[1]; /* this side is ours */
@@ -606,7 +607,11 @@
     }
     address[address_len] = 0; /* null terminate it */
 
-    switch (tor_lookup_hostname(address, &ip)) {
+    result = tor_lookup_hostname(address, &ip);
+    /* Make 0.0.0.0 an error, so that we can use "0" to mean "no addr") */
+    if (!ip)
+      result = -1;
+    switch (result) {
       case 1:
         log_fn(LOG_INFO,"Could not resolve dest addr %s (transient).",address);
         answer[0] = DNS_RESOLVE_FAILED_TRANSIENT;

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.84
retrieving revision 1.84.2.1
diff -u -d -r1.84 -r1.84.2.1
--- routerlist.c	2 Jun 2004 20:00:57 -0000	1.84
+++ routerlist.c	4 Jul 2004 04:53:32 -0000	1.84.2.1
@@ -481,7 +481,8 @@
 static int
 router_resolve(routerinfo_t *router)
 {
-  if (tor_lookup_hostname(router->address, &router->addr) != 0) {
+  if (tor_lookup_hostname(router->address, &router->addr) != 0
+      || !router->addr) {
     log_fn(LOG_WARN,"Could not get address for router %s (%s).",
            router->address, router->nickname);
     return -1;



More information about the tor-commits mailing list