]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Detect OpenSSL memory functions' parameters via configure
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 5 Feb 2017 19:04:35 +0000 (21:04 +0200)
committerGitLab <gitlab@git.dovecot.net>
Mon, 6 Feb 2017 08:16:30 +0000 (10:16 +0200)
The version number check doesn't work correctly for LibreSSL.

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

index 548da8d35d27d7a6be8ca59804440ea7364c9b95..5f8503f3ac74a993bc974081c4a0d02ecdb8755a 100644 (file)
--- a/m4/ssl.m4
+++ b/m4/ssl.m4
@@ -61,6 +61,28 @@ AC_DEFUN([DOVECOT_SSL], [
         AC_DEFINE(HAVE_SSL_CLEAR_OPTIONS,, [Define if you have SSL_clear_options])
       fi
 
+      # New style mem functions? Should be in v1.1+
+      AC_CACHE_CHECK([whether CRYPTO_set_mem_functions has new style parameters],i_cv_have_ssl_new_mem_funcs,[
+        old_LIBS=$LIBS
+        LIBS="$LIBS -lssl"
+        AC_TRY_LINK([
+          #include <openssl/ssl.h>
+         int CRYPTO_set_mem_functions(
+                 void *(*m) (size_t, const char *, int),
+                 void *(*r) (void *, size_t, const char *, int),
+                 void (*f) (void *, const char *, int));
+        ], [
+        ], [
+          i_cv_have_ssl_new_mem_funcs=yes
+        ], [
+          i_cv_have_ssl_new_mem_funcs=no
+        ])
+        LIBS=$old_LIBS
+      ])
+      if test $i_cv_have_ssl_new_mem_funcs = yes; then
+        AC_DEFINE(HAVE_SSL_NEW_MEM_FUNCS,, [Define if CRYPTO_set_mem_functions has new style parameters])
+      fi
+
       # SSL_CTX_set1_curves_list is a macro so plain AC_CHECK_LIB fails here.
       AC_CACHE_CHECK([whether SSL_CTX_set1_curves_list exists],i_cv_have_ssl_ctx_set1_curves_list,[
         old_LIBS=$LIBS
index a2d4e6f526bd015dab1c37cba370a47bd42418a9..ece359b08fea0a4abac6398b1ccf26003a7dad21 100644 (file)
@@ -10,7 +10,7 @@
 static int openssl_init_refcount = 0;
 static ENGINE *dovecot_openssl_engine;
 
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#ifdef HAVE_SSL_NEW_MEM_FUNCS
 static void *dovecot_openssl_malloc(size_t size, const char *u0 ATTR_UNUSED, int u1 ATTR_UNUSED)
 #else
 static void *dovecot_openssl_malloc(size_t size)
@@ -26,7 +26,7 @@ static void *dovecot_openssl_malloc(size_t size)
        return mem;
 }
 
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#ifdef HAVE_SSL_NEW_MEM_FUNCS
 static void *dovecot_openssl_realloc(void *ptr, size_t size, const char *u0 ATTR_UNUSED, int u1 ATTR_UNUSED)
 #else
 static void *dovecot_openssl_realloc(void *ptr, size_t size)
@@ -40,7 +40,7 @@ static void *dovecot_openssl_realloc(void *ptr, size_t size)
        return mem;
 }
 
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#ifdef HAVE_SSL_NEW_MEM_FUNCS
 static void dovecot_openssl_free(void *ptr, const char *u0 ATTR_UNUSED, int u1 ATTR_UNUSED)
 #else
 static void dovecot_openssl_free(void *ptr)