]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix tor-resolve implementation to prevent crashes and send resolves when we should.
authorNick Mathewson <nickm@torproject.org>
Sat, 5 Feb 2005 21:03:24 +0000 (21:03 +0000)
committerNick Mathewson <nickm@torproject.org>
Sat, 5 Feb 2005 21:03:24 +0000 (21:03 +0000)
svn:r3561

src/or/connection_edge.c
src/or/dns.c

index 17b9cc41dd047b74e46d9871c42e0acf90730ec1..e67be3dfcfcbcd7a0a04248995246d8135637216 100644 (file)
@@ -904,18 +904,17 @@ int connection_exit_begin_resolve(cell_t *cell, circuit_t *circ) {
   dummy_conn->state = EXIT_CONN_STATE_RESOLVEFAILED;
   dummy_conn->purpose = EXIT_PURPOSE_RESOLVE;
 
-  dummy_conn->next_stream = circ->resolving_streams;
-  circ->resolving_streams = dummy_conn;
-
   /* send it off to the gethostbyname farm */
   switch (dns_resolve(dummy_conn)) {
     case 1: /* The result was cached; a resolved cell was sent. */
-    case -1:
-      /* dummy_conn got freed, don't touch it */
+    case -1: /* Impossible to resolve; a resolved cell was sent. */
+      connection_free(dummy_conn);
       return 0;
     case 0: /* resolve added to pending list */
+      dummy_conn->next_stream = circ->resolving_streams;
+      circ->resolving_streams = dummy_conn;
       assert_circuit_ok(circ);
-      ;
+      break;
   }
   return 0;
 }
index 5e68c63f9d7d2e6e6f3a766b56c46d2a1d2635b5..7b23f60ea9e40c4787a60d7bc69ab97a32236801 100644 (file)
@@ -216,6 +216,8 @@ int dns_resolve(connection_t *exitconn) {
    * know the answer. */
   if (tor_inet_aton(exitconn->address, &in) != 0) {
     exitconn->addr = ntohl(in.s_addr);
+    if (exitconn->purpose == EXIT_PURPOSE_RESOLVE)
+      send_resolved_cell(exitconn, RESOLVED_TYPE_IPV4);
     return 1;
   }