aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-04-20 16:23:06 +0200
committerNick Mathewson <nickm@torproject.org>2017-04-25 08:10:10 -0400
commitc2d1d949dec1db9fb413a02be422dfede3bb53aa (patch)
tree4ad2a4926952afe396fa8aaef516e4d3c29de7dc /src/or
parent6b905b38bb850d0530ba6f6d02c10b1fb19aef9a (diff)
downloadtor-c2d1d949dec1db9fb413a02be422dfede3bb53aa.tar.gz
tor-c2d1d949dec1db9fb413a02be422dfede3bb53aa.zip
Use `tor_compress_supports_method()` before printing library versions.
This patch ensures that Tor checks if a given compression method is supported before printing the version string when calling `tor --library-versions`. Additionally, we use the `tor_compress_supports_method()` to check if a given version is supported for Tor's start-up version string, but here we print "N/A" if a given compression method is unavailable. See: https://bugs.torproject.org/21662
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c27
-rw-r--r--src/or/main.c13
2 files changed, 22 insertions, 18 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 3549a1d608..a73f397073 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -70,9 +70,6 @@
#include "circuitmux_ewma.h"
#include "circuitstats.h"
#include "compress.h"
-#include "compress_lzma.h"
-#include "compress_zlib.h"
-#include "compress_zstd.h"
#include "config.h"
#include "connection.h"
#include "connection_edge.h"
@@ -4952,15 +4949,21 @@ options_init_from_torrc(int argc, char **argv)
printf("OpenSSL \t\t%-15s\t\t%s\n",
crypto_openssl_get_header_version_str(),
crypto_openssl_get_version_str());
- printf("Zlib \t\t%-15s\t\t%s\n",
- tor_zlib_get_header_version_str(),
- tor_zlib_get_version_str());
- printf("Liblzma \t\t%-15s\t\t%s\n",
- tor_lzma_get_header_version_str(),
- tor_lzma_get_version_str());
- printf("Libzstd \t\t%-15s\t\t%s\n",
- tor_zstd_get_header_version_str(),
- tor_zstd_get_version_str());
+ if (tor_compress_supports_method(ZLIB_METHOD)) {
+ printf("Zlib \t\t%-15s\t\t%s\n",
+ tor_compress_version_str(ZLIB_METHOD),
+ tor_compress_header_version_str(ZLIB_METHOD));
+ }
+ if (tor_compress_supports_method(LZMA_METHOD)) {
+ printf("Liblzma \t\t%-15s\t\t%s\n",
+ tor_compress_version_str(LZMA_METHOD),
+ tor_compress_header_version_str(LZMA_METHOD));
+ }
+ if (tor_compress_supports_method(ZSTD_METHOD)) {
+ printf("Libzstd \t\t%-15s\t\t%s\n",
+ tor_compress_version_str(ZSTD_METHOD),
+ tor_compress_header_version_str(ZSTD_METHOD));
+ }
//TODO: Hex versions?
exit(0);
}
diff --git a/src/or/main.c b/src/or/main.c
index f3a0d84aea..1ba6554d3e 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -58,9 +58,7 @@
#include "circuitlist.h"
#include "circuituse.h"
#include "command.h"
-#include "compress_lzma.h"
-#include "compress_zlib.h"
-#include "compress_zstd.h"
+#include "compress.h"
#include "config.h"
#include "confparse.h"
#include "connection.h"
@@ -3005,9 +3003,12 @@ tor_init(int argc, char *argv[])
get_uname(),
tor_libevent_get_version_str(),
crypto_openssl_get_version_str(),
- tor_zlib_get_version_str(),
- tor_lzma_get_version_str(),
- tor_zstd_get_version_str());
+ tor_compress_supports_method(ZLIB_METHOD) ?
+ tor_compress_version_str(ZLIB_METHOD) : "N/A",
+ tor_compress_supports_method(LZMA_METHOD) ?
+ tor_compress_version_str(LZMA_METHOD) : "N/A",
+ tor_compress_supports_method(ZSTD_METHOD) ?
+ tor_compress_version_str(ZSTD_METHOD) : "N/A");
log_notice(LD_GENERAL, "Tor can't help you if you use it wrong! "
"Learn how to be safe at "