[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Fix bug 221 and bug 201: For 221, check return value from c...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv18131/src/or

Modified Files:
	directory.c 
Log Message:
Fix bug 221 and bug 201: For 221, check return value from connection_add() when adding a rendezvous post connection.  For 201, do not include a content-length 0 with a GET request.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.339
retrieving revision 1.340
diff -u -p -d -r1.339 -r1.340
--- directory.c	9 Jan 2006 23:13:52 -0000	1.339
+++ directory.c	10 Jan 2006 19:24:40 -0000	1.340
@@ -451,8 +451,12 @@ directory_initiate_command(const char *a
       return;
     }
 
+    if (connection_add(conn) < 0) {
+      warn(LD_NET,"Unable to add AP bridge to dirserver.");
+      connection_mark_for_close(conn);
+      return;
+    }
     conn->state = DIR_CONN_STATE_CLIENT_SENDING;
-    connection_add(conn);
     /* queue the command on the outbuf */
     directory_send_command(conn, platform, purpose, resource,
                            payload, payload_len);
@@ -580,11 +584,18 @@ directory_send_command(connection_t *con
   connection_write_to_buf(url, strlen(url), conn);
   tor_free(url);
 
-  tor_snprintf(request, sizeof(request),
-               " HTTP/1.0\r\nContent-Length: %lu\r\nHost: %s%s\r\n\r\n",
-           payload ? (unsigned long)payload_len : 0,
-           hoststring,
-           proxyauthstring);
+  if (!strcmp(httpcommand, "GET") && !payload) {
+    tor_snprintf(request, sizeof(request),
+                 " HTTP/1.0\r\nHost: %s%s\r\n\r\n",
+                 hoststring,
+                 proxyauthstring);
+  } else {
+    tor_snprintf(request, sizeof(request),
+                 " HTTP/1.0\r\nContent-Length: %lu\r\nHost: %s%s\r\n\r\n",
+                 payload ? (unsigned long)payload_len : 0,
+                 hoststring,
+                 proxyauthstring);
+  }
   connection_write_to_buf(request, strlen(request), conn);
 
   if (payload) {