]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
LibreSSL compatibility fixes.
authorNick Mathewson <nickm@torproject.org>
Wed, 2 May 2018 12:18:48 +0000 (08:18 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 2 May 2018 12:22:05 +0000 (08:22 -0400)
LibreSSL, despite not having the OpenSSL 1.1 API, does define
OPENSSL_VERSION in crypto.h.  Additionally, it apparently annotates
some functions as returning NULL, so that our unit tests need to be
more careful about checking for NULL so they don't get compilation
warnings.

Closes ticket 26006.

changes/ticket26006 [new file with mode: 0644]
src/common/compat_openssl.h
src/test/test_tortls.c

diff --git a/changes/ticket26006 b/changes/ticket26006
new file mode 100644 (file)
index 0000000..e33e3f1
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor features (compilation, portability):
+    - Avoid some compilation warnings with recent versions
+      of LibreSSL. Closes ticket 26006.
+
index 1bfe18807590caa42be5118932d3a692f828baef..76679872bc6366ae80a5e3921b0d483dfe733bd7 100644 (file)
@@ -8,6 +8,8 @@
 #define TOR_COMPAT_OPENSSL_H
 
 #include <openssl/opensslv.h>
+// workaround for libressl; not needed in later Tor versions.
+#include <openssl/crypto.h>
 
 /**
  * \file compat_openssl.h
 #define OPENSSL_1_1_API
 #endif
 
-#ifndef OPENSSL_1_1_API
+#ifndef OPENSSL_VERSION
 #define OPENSSL_VERSION SSLEAY_VERSION
+#endif
+
+#ifndef OPENSSL_1_1_API
 #define OpenSSL_version(v) SSLeay_version(v)
 #define OpenSSL_version_num() SSLeay()
 #define RAND_OpenSSL() RAND_SSLeay()
index 47455cff838d4afbfbbfd453cc081428e342d85e..5028a95400616cc9aebf03e8b36fa91aa25cc984 100644 (file)
@@ -840,8 +840,10 @@ test_tortls_classify_client_ciphers(void *ignored)
   sk_SSL_CIPHER_zero(ciphers);
 
   one = get_cipher_by_name("ECDHE-RSA-AES256-GCM-SHA384");
+  tt_assert(one);
   one->id = 0x00ff;
   two = get_cipher_by_name("ECDHE-RSA-AES128-GCM-SHA256");
+  tt_assert(two);
   two->id = 0x0000;
   sk_SSL_CIPHER_push(ciphers, one);
   tls->client_cipher_list_type = 0;
@@ -912,6 +914,7 @@ test_tortls_client_is_using_v2_ciphers(void *ignored)
 
   ciphers = sk_SSL_CIPHER_new_null();
   SSL_CIPHER *one = get_cipher_by_name("ECDHE-RSA-AES256-GCM-SHA384");
+  tt_assert(one);
   one->id = 0x00ff;
   sk_SSL_CIPHER_push(ciphers, one);
   sess->ciphers = ciphers;