[or-cvs] r13054: Consequence of fix for 539: when a client gets a 503 respons (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Mon Jan 7 17:49:13 UTC 2008


Author: nickm
Date: 2008-01-07 12:49:13 -0500 (Mon, 07 Jan 2008)
New Revision: 13054

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/directory.c
Log:
 r17495 at catbus:  nickm | 2008-01-07 12:48:56 -0500
 Consequence of fix for 539: when a client gets a 503 response with a nontrivial body, pretend it got a 200 response.  This lets clients use information erroneously sent to them by old buggy servers.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r17495] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-01-07 16:50:33 UTC (rev 13053)
+++ tor/trunk/ChangeLog	2008-01-07 17:49:13 UTC (rev 13054)
@@ -10,6 +10,10 @@
     - Configuration files now accept C-style strings as values.  This
       helps encode characters not allowed in the current configuration
       file format, such as newline or #.  Addresses bug 557.
+    - Although we fixed bug 539 (where servers would send HTTP status 503
+      responses _and_ send a body too), there are still servers out there
+      that haven't upgraded.  Therefore, make clients parse such bodies
+      when they receive them.
 
   o Minor performance improvements:
     - Reference-count and share copies of address policy entries; only

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2008-01-07 16:50:33 UTC (rev 13053)
+++ tor/trunk/src/or/directory.c	2008-01-07 17:49:13 UTC (rev 13054)
@@ -1280,7 +1280,7 @@
   }
   (void) skewed; /* skewed isn't used yet. */
 
-  if (status_code == 503) {
+  if (status_code == 503 && body_len < 16) {
     routerstatus_t *rs;
     trusted_dir_server_t *ds;
     log_info(LD_DIR,"Received http status code %d (%s) from server "
@@ -1294,6 +1294,12 @@
 
     tor_free(body); tor_free(headers); tor_free(reason);
     return -1;
+  } else if (status_code == 503) {
+    /* XXXX022 Remove this once every server with bug 539 is obsolete. */
+    log_info(LD_DIR, "Server at '%s:%d' sent us a 503 response, but included "
+             "a body anyway.  We'll pretend it gave us a 200.",
+             conn->_base.address, conn->_base.port);
+    status_code = 200;
   }
 
   plausible = body_is_plausible(body, body_len, conn->_base.purpose);



More information about the tor-commits mailing list