[tor-commits] [tor/master] Fix: our directory.c code expects header constants to end with a :

nickm at torproject.org nickm at torproject.org
Thu May 4 12:58:39 UTC 2017


commit baf489fc08c5f90b8ee0f00c15b1f6bb91c38926
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu May 4 08:57:34 2017 -0400

    Fix: our directory.c code expects header constants to end with a :
---
 src/or/directory.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index 917dfee..d31dd2f 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -131,7 +131,7 @@ static void directory_request_set_guard_state(directory_request_t *req,
 #define ALLOW_DIRECTORY_TIME_SKEW (30*60)
 
 #define X_ADDRESS_HEADER "X-Your-Address-Is: "
-#define X_OR_DIFF_FROM_CONSENSUS_HEADER "X-Or-Diff-From-Consensus"
+#define X_OR_DIFF_FROM_CONSENSUS_HEADER "X-Or-Diff-From-Consensus: "
 
 /** HTTP cache control: how long do we tell proxies they can cache each
  * kind of document we serve? */
@@ -1226,6 +1226,9 @@ directory_request_set_if_modified_since(directory_request_t *req,
 /** Include a header of name <b>key</b> with content <b>val</b> in the
  * request. Neither may include newlines or other odd characters. Their
  * ordering is not currently guaranteed.
+ *
+ * Note that, as elsewhere in this module, header keys include a trailing
+ * colon and space.
  */
 void
 directory_request_add_header(directory_request_t *req,
@@ -1724,7 +1727,7 @@ directory_send_command(dir_connection_t *conn,
   {
     config_line_t *h;
     for (h = req->additional_headers; h; h = h->next) {
-      smartlist_add_asprintf(headers, "%s: %s\r\n", h->key, h->value);
+      smartlist_add_asprintf(headers, "%s%s\r\n", h->key, h->value);
     }
   }
 
@@ -3508,7 +3511,7 @@ directory_handle_command_get,(dir_connection_t *conn, const char *headers,
     url_len -= 2;
   }
 
-  if ((header = http_get_header(headers, "Accept-Encoding"))) {
+  if ((header = http_get_header(headers, "Accept-Encoding: "))) {
     compression_methods_supported = parse_accept_encoding_header(header);
     tor_free(header);
   } else {





More information about the tor-commits mailing list