]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
When tor_lookup_hostname says 0.0.0.0, treat it as an error.
authorNick Mathewson <nickm@torproject.org>
Sun, 4 Jul 2004 04:52:43 +0000 (04:52 +0000)
committerNick Mathewson <nickm@torproject.org>
Sun, 4 Jul 2004 04:52:43 +0000 (04:52 +0000)
svn:r2003

src/or/dns.c
src/or/routerlist.c

index 66e9334b1445e7a979a253e0c5d24586a191a852..851041d779b2875e14d35a54448a8d04bb4348f9 100644 (file)
@@ -634,6 +634,7 @@ static int dnsworker_main(void *data) {
   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 */
@@ -655,7 +656,11 @@ static int dnsworker_main(void *data) {
     }
     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 1c9d83756fe423dc616f107b9e565ec9770e37d2..1d03a6d1b01133a87985f1d1744e7a7ae8acf346 100644 (file)
@@ -237,7 +237,7 @@ int router_nickname_matches(routerinfo_t *router, const char *nickname)
  */
 routerinfo_t *router_get_by_nickname(const char *nickname)
 {
-  int i, maybedigest, mustbedigest;
+  int i, maybedigest;
   routerinfo_t *router;
   char digest[DIGEST_LEN];
 
@@ -562,7 +562,8 @@ int router_load_routerlist_from_directory(const char *s,
 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;