]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix bug reported by peter palfrader: an empty address is unresolvable, but not an...
authorNick Mathewson <nickm@torproject.org>
Tue, 6 Jul 2004 23:25:21 +0000 (23:25 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 6 Jul 2004 23:25:21 +0000 (23:25 +0000)
svn:r2015

src/common/util.c
src/or/dns.c

index 27d43337afbabdd4345629259cadbeed97f2b7c7..cc90495becd043fc30b6a5043e78e946426970d9 100644 (file)
@@ -1709,7 +1709,10 @@ int tor_lookup_hostname(const char *name, uint32_t *addr)
   struct in_addr iaddr;
   struct hostent *ent;
   tor_assert(addr);
-  if (tor_inet_aton(name, &iaddr)) {
+  if (!*name) {
+    /* Empty address is an error. */
+    return -1;
+  } if (tor_inet_aton(name, &iaddr)) {
     /* It's an IP. */
     memcpy(addr, &iaddr.s_addr, 4);
     return 0;
index 851041d779b2875e14d35a54448a8d04bb4348f9..3e16b6b643ffa317b366df441f6589aa0cc7459f 100644 (file)
@@ -648,9 +648,8 @@ static int dnsworker_main(void *data) {
       log_fn(LOG_INFO,"dnsworker exiting because tor process died.");
       spawn_exit();
     }
-    tor_assert(address_len > 0);
 
-    if(read_all(fd, address, address_len, 1) != address_len) {
+    if(address_len && read_all(fd, address, address_len, 1) != address_len) {
       log_fn(LOG_ERR,"read hostname failed. Child exiting.");
       spawn_exit();
     }