Skip to content

Commit

Permalink
lib-ssl-iostream: Detect OpenSSL memory functions' parameters via con…
Browse files Browse the repository at this point in the history
…figure

The version number check doesn't work correctly for LibreSSL.
  • Loading branch information
sirainen committed Feb 6, 2017
1 parent 905553c commit 6c74870
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
22 changes: 22 additions & 0 deletions configure.ac
Expand Up @@ -1747,6 +1747,28 @@ if test $want_openssl != no && test $have_ssl = no; then
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

AC_CHECK_LIB(ssl, SSL_get_current_compression, [
AC_DEFINE(HAVE_SSL_COMPRESSION,, [Build with OpenSSL compression])
],, $SSL_LIBS)
Expand Down
6 changes: 3 additions & 3 deletions src/lib-ssl-iostream/dovecot-openssl-common.c
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6c74870

Please sign in to comment.