]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Use ASN1_STRING_get0_data() if it exists
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 5 Feb 2017 19:56:20 +0000 (21:56 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 6 Feb 2017 14:34:11 +0000 (16:34 +0200)
This avoids deprecation warnings about ASN1_STRING_data() in OpenSSL v1.1.

configure.ac
src/lib-ssl-iostream/iostream-openssl-common.c
src/lib-ssl-iostream/iostream-openssl.h

index f223378168943925140e6bb3ed6445010911e639..3f9afd4c6da2f978813286fe572b516e09ecb2ce 100644 (file)
@@ -1759,6 +1759,9 @@ if test $want_openssl != no && test $have_ssl = no; then
     AC_CHECK_LIB(ssl, RSA_generate_key_ex, [
       AC_DEFINE(HAVE_RSA_GENERATE_KEY_EX,, [Build with RSA_generate_key_ex() support])
     ],, $SSL_LIBS)
+    AC_CHECK_LIB(ssl, ASN1_STRING_get0_data, [
+      AC_DEFINE(HAVE_ASN1_STRING_GET0_DATA,, [Build with ASN1_STRING_get0_data() support])
+    ],, $SSL_LIBS)
     AC_CHECK_LIB(ssl, [EVP_PKEY_CTX_new_id], [have_evp_pkey_ctx_new_id="yes"],, $SSL_LIBS)
     AC_CHECK_LIB(ssl, [EC_KEY_new], [have_ec_key_new="yes"],, $SSL_LIBS)
     if test "$have_evp_pkey_ctx_new_id" = "yes" && test "$have_ec_key_new" = "yes"; then
index 5eb48aa2bc71b950b3d10afa64919c5699feb2fc..d88b2ad4e48316021cafb2770ce598814b724580 100644 (file)
@@ -84,7 +84,7 @@ static const char *asn1_string_to_c(ASN1_STRING *asn_str)
        unsigned int len;
 
        len = ASN1_STRING_length(asn_str);
-       cstr = t_strndup(ASN1_STRING_data(asn_str), len);
+       cstr = t_strndup(ASN1_STRING_get0_data(asn_str), len);
        if (strlen(cstr) != len) {
                /* NULs in the name - could be some MITM attack.
                   never allow. */
index 37b86608efed5f19b75fbf85c78829fb8723eecd..d46d608d10e87992fe1e3cd803fd92b5313b91de 100644 (file)
@@ -5,6 +5,10 @@
 
 #include <openssl/ssl.h>
 
+#ifndef HAVE_ASN1_STRING_GET0_DATA
+#  define ASN1_STRING_get0_data(str) ASN1_STRING_data(str)
+#endif
+
 struct ssl_iostream_context {
        SSL_CTX *ssl_ctx;