commit 65ff0f8267b99a55a099eec2a71cb45557ae84eb Author: Nick Mathewson nickm@torproject.org Date: Tue Apr 25 19:07:17 2017 -0400
Bitmask out the compression methods that we do not support --- src/or/directory.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/src/or/directory.c b/src/or/directory.c index 95c3c84..ea3410d 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;