Commit 720c5ee8 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

configure: fix detection of memory cleanup functions

parent c71a5c4f
......@@ -165,6 +165,10 @@ PKG_CHECK_MODULES([gnutls], [gnutls >= 3.3], [
AC_CHECK_FUNC([gnutls_privkey_sign_data2],
[AC_DEFINE([HAVE_SIGN_DATA2], [1], [gnutls_privkey_sign_data2 available])])
AC_CHECK_FUNC([gnutls_memset],
[AC_DEFINE([HAVE_GNUTLS_MEMSET], [1], [gnutls_memset available])
gnutls_memset=yes], [gnutls_memset=no])
CFLAGS=$save_CFLAGS
LIBS=$save_LIBS
])
......@@ -605,11 +609,15 @@ AC_CHECK_HEADERS_ONCE([pthread_np.h sys/uio.h bsd/string.h])
AC_CHECK_FUNCS([accept4 clock_gettime fgetln getline initgroups malloc_trim \
setgroups strlcat strlcpy sysctlbyname])
AC_CHECK_FUNC([explicit_bzero], [explicit_bzero=yes], [explicit_bzero=no])
AM_CONDITIONAL([EXPLICIT_BZERO], [test "$explicit_bzero" = "yes"])
AC_CHECK_FUNC([explicit_memset], [explicit_memset=yes], [explicit_memset=no])
AM_CONDITIONAL([EXPLICIT_MEMSET], [test "$explicit_memset" = "yes"])
AC_CHECK_DECL([gnutls_memset], [gnutls_memset=yes], [gnutls_memset=no], [#include <gnutls/gnutls.h>])
# Check for robust memory cleanup implementations.
AC_CHECK_FUNC([explicit_bzero], [
AC_DEFINE([HAVE_EXPLICIT_BZERO], [1], [explicit_bzero available])
explicit_bzero=yes], [explicit_bzero=no]
)
AC_CHECK_FUNC([explicit_memset], [
AC_DEFINE([HAVE_EXPLICIT_MEMSET], [1], [explicit_memset available])
explicit_memset=yes], [explicit_memset=no]
)
AM_CONDITIONAL([USE_GNUTLS_MEMSET], [test "$explicit_bzero" = "no" -a "$explicit_memset" = "no" -a "$gnutls_memset" = "yes"])
# Check for mandatory library functions.
......
......@@ -134,13 +134,11 @@ void *memzero(void *s, size_t n)
#elif defined(HAVE_GNUTLS_MEMSET) /* In GnuTLS since 3.4.0. */
gnutls_memset(s, 0, n);
return s;
#elif defined(USE_CUSTOM_MEMSET) /* Knot custom solution as a fallback. */
#else /* Knot custom solution as a fallback. */
/* Warning: the use of the return value is *probably* needed
* so as to avoid the volatile_memset() to be optimized out.
*/
return volatile_memset(s, 0, n);
#else
#error Build of memzero() failed!
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment