aboutsummaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-25 19:07:17 -0400
committerNick Mathewson <nickm@torproject.org>2017-04-25 19:07:17 -0400
commit65ff0f8267b99a55a099eec2a71cb45557ae84eb (patch)
tree293d2e48caadf5765839b268a3cbaf4b9e63fa41 /src/or/directory.c
parentfec3050ea968ae913b108a4c48bce2293b92072c (diff)
downloadtor-65ff0f8267b99a55a099eec2a71cb45557ae84eb.tar.gz
tor-65ff0f8267b99a55a099eec2a71cb45557ae84eb.zip
Bitmask out the compression methods that we do not support
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 95c3c8481e..ea3410d8c6 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2814,6 +2814,20 @@ parse_accept_encoding_header(const char *h)
return result;
}
+/** Bitmask of supported compression types, to use in a bitwise "and"
+ * with the results of parse_accept_encoding_header */
+static const unsigned SUPPORTED_COMPRESSION_MASK =
+ (1u << NO_METHOD)
+ | (1u << ZLIB_METHOD)
+ | (1u << GZIP_METHOD)
+#ifdef HAVE_ZSTD
+ | (1u << ZSTD_METHOD)
+#endif
+#ifdef HAVE_LZMA
+ | (1u << LZMA_METHOD)
+#endif
+ ;
+
/** Decide whether a client would accept the consensus we have.
*
* Clients can say they only want a consensus if it's signed by more
@@ -3013,6 +3027,9 @@ directory_handle_command_get,(dir_connection_t *conn, const char *headers,
compression_methods_supported |= (1u << ZLIB_METHOD);
}
+ /* Remove all methods that we don't both support. */
+ compression_methods_supported &= SUPPORTED_COMPRESSION_MASK;
+
get_handler_args_t args;
args.url = url;
args.headers = headers;