You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2019/08/21 14:03:14 UTC

[mesos] branch master updated: Moved OpenSSL-related ifdef to a central location.

This is an automated email from the ASF dual-hosted git repository.

bennoe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 888d088  Moved OpenSSL-related ifdef to a central location.
888d088 is described below

commit 888d088ea25f4bf872874efae85ff56267cfc7aa
Author: Benno Evers <be...@mesosphere.com>
AuthorDate: Wed Aug 21 15:31:30 2019 +0200

    Moved OpenSSL-related ifdef to a central location.
    
    A previous commit introduced an preprocessor directive that would
    split up code between brackets, confusing syntax highlighters and
    making the logic hard to read.
    
    Review: https://reviews.apache.org/r/71338/
---
 3rdparty/libprocess/src/openssl.cpp | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/3rdparty/libprocess/src/openssl.cpp b/3rdparty/libprocess/src/openssl.cpp
index ef2883a..5854711 100644
--- a/3rdparty/libprocess/src/openssl.cpp
+++ b/3rdparty/libprocess/src/openssl.cpp
@@ -51,6 +51,14 @@
 // family of functions was backported. (OpenSSL 1.0.2)
 #define MIN_VERSION_X509_VERIFY_PARAM 0x10002000L
 
+// Smallest OpenSSL version number that deprecated the `ASN1_STRING_data()`
+// function in favor of `ASN1_STRING_get0_data()`. (OpenSSL 1.1.0)
+#define MIN_VERSION_ASN1_STRING_GET0 0x10100000L
+
+#if OPENSSL_VERSION_NUMBER < MIN_VERSION_ASN1_STRING_GET0
+#  define ASN1_STRING_get0_data ASN1_STRING_data
+#endif
+
 using std::map;
 using std::ostringstream;
 using std::string;
@@ -885,14 +893,8 @@ Try<Nothing> verify(
         case GEN_DNS: {
           if (peer_hostname.isSome()) {
             // Current name is a DNS name, let's check it.
-            const string dns_name =
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
-              // `ASN1_STRING_data` is deprecated since OpenSSL 1.1.0.
-              reinterpret_cast<char*>(ASN1_STRING_data(
-#else
-              reinterpret_cast<const char*>(ASN1_STRING_get0_data(
-#endif // OPENSSL_VERSION_NUMBER < 0x10100000L
-                  current_name->d.dNSName));
+            const string dns_name = reinterpret_cast<const char*>(
+                ASN1_STRING_get0_data(current_name->d.dNSName));
 
             // Make sure there isn't an embedded NUL character in the DNS name.
             const size_t length = ASN1_STRING_length(current_name->d.dNSName);