]> 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)
committerGitLab <gitlab@git.dovecot.net>
Mon, 6 Feb 2017 08:15:46 +0000 (10:15 +0200)
This avoids deprecation warnings about ASN1_STRING_data() in OpenSSL v1.1.

m4/ssl.m4
src/lib-ssl-iostream/iostream-openssl-common.c
src/lib-ssl-iostream/iostream-openssl.h

index 4c98095a129d566f1af0235a194c7d429a1ce7f3..548da8d35d27d7a6be8ca59804440ea7364c9b95 100644 (file)
--- a/m4/ssl.m4
+++ b/m4/ssl.m4
@@ -92,6 +92,9 @@ AC_DEFUN([DOVECOT_SSL], [
       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 6a26907cc980fcdc5d53f84935ebab83c5b666d1..b772c70e88e8a3afdb1163fa685f46f38c9b7429 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 11913c8eb0438f77cacba43907b24b3876a3e6db..bb87ff05ad01634417fec10d73db1c6806105768 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;