[or-cvs] Fix a few bugs in sending and receiving DNS results

Nick Mathewson nickm at seul.org
Sun Nov 23 18:16:11 UTC 2003


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

Modified Files:
	connection_edge.c 
Log Message:
Fix a few bugs in sending and receiving DNS results

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- connection_edge.c	19 Nov 2003 02:22:52 -0000	1.65
+++ connection_edge.c	23 Nov 2003 18:16:06 -0000	1.66
@@ -253,7 +253,7 @@
          * we try a new exit node.
          * cell->payload+RELAY_HEADER_SIZE+1 holds the destination addr.
          */
-        addr = ntohl(*cell->payload+RELAY_HEADER_SIZE+1);
+        addr = ntohl(*(uint32_t*)(cell->payload+RELAY_HEADER_SIZE+1));
         client_dns_set_entry(conn->socks_request->address, addr);
         conn->state = AP_CONN_STATE_CIRCUIT_WAIT;
         if(connection_ap_handshake_attach_circuit(conn) < 0)
@@ -328,7 +328,7 @@
       }
       log_fn(LOG_INFO,"Connected! Notifying application.");
       if (cell->length-RELAY_HEADER_SIZE == 4) {
-        addr = htonl(*(uint32_t*)(cell->payload + RELAY_HEADER_SIZE));
+        addr = ntohl(*(uint32_t*)(cell->payload + RELAY_HEADER_SIZE));
         client_dns_set_entry(conn->socks_request->address, addr);
       }
       if(connection_ap_handshake_socks_reply(conn, NULL, 0, 1) < 0) {
@@ -365,6 +365,7 @@
 }
 
 int connection_edge_finished_flushing(connection_t *conn) {
+  unsigned char connected_payload[4];
   int e, len=sizeof(e);
 
   assert(conn);
@@ -392,6 +393,7 @@
       if(connection_wants_to_flush(conn)) /* in case there are any queued relay cells */
         connection_start_writing(conn);
       /* deliver a 'connected' relay cell back through the circuit. */
+      *(uint32_t*)connected_payload = htonl(conn->addr);
       if(connection_edge_send_command(conn, circuit_get_by_conn(conn),
          RELAY_COMMAND_CONNECTED, NULL, 0, conn->cpath_layer) < 0)
         return 0; /* circuit is closed, don't continue */
@@ -592,6 +594,7 @@
   /* add it into the linked list of streams on this circuit */
   log_fn(LOG_DEBUG,"attaching new conn to circ. n_circ_id %d.", circ->n_circ_id);
   conn->next_stream = circ->p_streams;
+  /* assert_connection_ok(conn, time(NULL)); */
   circ->p_streams = conn;
 
   assert(circ->cpath && circ->cpath->prev);
@@ -879,7 +882,9 @@
   now = time(NULL);
   ent = SPLAY_FIND(client_dns_tree, &client_dns_root, &search);
   if (ent) {
-    log_fn(LOG_DEBUG, "Updating entry for address %s", address);
+    in.s_addr = htonl(val);
+    log_fn(LOG_DEBUG, "Updating entry for address %s: %s", address,
+           inet_ntoa(in));
     ent->addr = val;
     ent->expires = now+MAX_DNS_ENTRY_AGE;
   } else {



More information about the tor-commits mailing list