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

[or-cvs] r13055: Backport: Consequence of fix for 539: when a client gets a 5 (in tor/branches/tor-0_1_2-patches: . src/or)



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

Modified:
   tor/branches/tor-0_1_2-patches/
   tor/branches/tor-0_1_2-patches/ChangeLog
   tor/branches/tor-0_1_2-patches/src/or/directory.c
Log:
 r17496@catbus:  nickm | 2008-01-07 12:49:06 -0500
 Backport: 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/branches/tor-0_1_2-patches
___________________________________________________________________
 svk:merge ticket from /tor/012 [r17496] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/branches/tor-0_1_2-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_1_2-patches/ChangeLog	2008-01-07 17:49:13 UTC (rev 13054)
+++ tor/branches/tor-0_1_2-patches/ChangeLog	2008-01-07 17:49:22 UTC (rev 13055)
@@ -35,6 +35,10 @@
       directory caches, and then we learned about a new descriptor for
       that router, we weren't resetting our failure count. Reported
       by lodger.
+    - 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.
 
 
 Changes in version 0.1.2.18 - 2007-10-28

Modified: tor/branches/tor-0_1_2-patches/src/or/directory.c
===================================================================
--- tor/branches/tor-0_1_2-patches/src/or/directory.c	2008-01-07 17:49:13 UTC (rev 13054)
+++ tor/branches/tor-0_1_2-patches/src/or/directory.c	2008-01-07 17:49:22 UTC (rev 13055)
@@ -932,7 +932,7 @@
   }
   (void) skewed; /* skewed isn't used yet. */
 
-  if (status_code == 503) {
+  if (status_code == 503 && body_len < 16) {
     local_routerstatus_t *rs;
     trusted_dir_server_t *ds;
     time_t now = time(NULL);
@@ -947,6 +947,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);