Add freezero support
This commit is contained in:
parent
9d2418ae3a
commit
048625cf2b
1
.gitignore
vendored
1
.gitignore
vendored
@ -143,6 +143,7 @@ include/openssl/*.h
|
|||||||
!/crypto/compat/arc4random.h
|
!/crypto/compat/arc4random.h
|
||||||
!/crypto/compat/b_win.c
|
!/crypto/compat/b_win.c
|
||||||
!/crypto/compat/explicit_bzero_win.c
|
!/crypto/compat/explicit_bzero_win.c
|
||||||
|
!/crypto/compat/freezero.c
|
||||||
!/crypto/compat/getpagesize.c
|
!/crypto/compat/getpagesize.c
|
||||||
!/crypto/compat/posix_win.c
|
!/crypto/compat/posix_win.c
|
||||||
!/crypto/compat/bsd_asprintf.c
|
!/crypto/compat/bsd_asprintf.c
|
||||||
|
@ -681,6 +681,11 @@ if(NOT HAVE_ASPRINTF)
|
|||||||
set(EXTRA_EXPORT ${EXTRA_EXPORT} vasprintf)
|
set(EXTRA_EXPORT ${EXTRA_EXPORT} vasprintf)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT HAVE_FREEZERO)
|
||||||
|
set(CRYPTO_SRC ${CRYPTO_SRC} compat/freezero.c)
|
||||||
|
set(EXTRA_EXPORT ${EXTRA_EXPORT} freezero)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT HAVE_GETPAGESIZE)
|
if(NOT HAVE_GETPAGESIZE)
|
||||||
set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c)
|
set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c)
|
||||||
endif()
|
endif()
|
||||||
|
@ -84,6 +84,10 @@ if !HAVE_ASPRINTF
|
|||||||
libcompat_la_SOURCES += compat/bsd-asprintf.c
|
libcompat_la_SOURCES += compat/bsd-asprintf.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !HAVE_FREEZERO
|
||||||
|
libcompat_la_SOURCES += compat/freezero.c
|
||||||
|
endif
|
||||||
|
|
||||||
if !HAVE_GETPAGESIZE
|
if !HAVE_GETPAGESIZE
|
||||||
libcompat_la_SOURCES += compat/getpagesize.c
|
libcompat_la_SOURCES += compat/getpagesize.c
|
||||||
endif
|
endif
|
||||||
|
13
crypto/compat/freezero.c
Normal file
13
crypto/compat/freezero.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
freezero(void *ptr, size_t sz)
|
||||||
|
{
|
||||||
|
/* This is legal. */
|
||||||
|
if (ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
explicit_bzero(ptr, sz);
|
||||||
|
free(ptr);
|
||||||
|
}
|
@ -25,6 +25,10 @@ void arc4random_buf(void *_buf, size_t n);
|
|||||||
uint32_t arc4random_uniform(uint32_t upper_bound);
|
uint32_t arc4random_uniform(uint32_t upper_bound);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_FREEZERO
|
||||||
|
void freezero(void *ptr, size_t sz);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_REALLOCARRAY
|
#ifndef HAVE_REALLOCARRAY
|
||||||
void *reallocarray(void *, size_t, size_t);
|
void *reallocarray(void *, size_t, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,11 +2,12 @@ AC_DEFUN([CHECK_LIBC_COMPAT], [
|
|||||||
# Check for libc headers
|
# Check for libc headers
|
||||||
AC_CHECK_HEADERS([err.h readpassphrase.h])
|
AC_CHECK_HEADERS([err.h readpassphrase.h])
|
||||||
# Check for general libc functions
|
# Check for general libc functions
|
||||||
AC_CHECK_FUNCS([asprintf getpagesize inet_ntop inet_pton memmem readpassphrase])
|
AC_CHECK_FUNCS([asprintf freezero getpagesize inet_ntop inet_pton memmem])
|
||||||
AC_CHECK_FUNCS([reallocarray recallocarray])
|
AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray])
|
||||||
AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
|
AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
|
||||||
AC_CHECK_FUNCS([timegm _mkgmtime])
|
AC_CHECK_FUNCS([timegm _mkgmtime])
|
||||||
AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
|
AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
|
||||||
|
AM_CONDITIONAL([HAVE_FREEZERO], [test "x$ac_cv_func_freezero" = xyes])
|
||||||
AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes])
|
AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes])
|
||||||
AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes])
|
AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes])
|
||||||
AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes])
|
AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes])
|
||||||
@ -170,6 +171,9 @@ fi
|
|||||||
if test "x$ac_cv_func_explicit_bzero" = "xno" ; then
|
if test "x$ac_cv_func_explicit_bzero" = "xno" ; then
|
||||||
echo explicit_bzero >> $crypto_p_sym
|
echo explicit_bzero >> $crypto_p_sym
|
||||||
fi
|
fi
|
||||||
|
if test "x$ac_cv_func_freezero" = "xno" ; then
|
||||||
|
echo freezero >> $crypto_p_sym
|
||||||
|
fi
|
||||||
if test "x$ac_cv_func_inet_pton" = "xno" ; then
|
if test "x$ac_cv_func_inet_pton" = "xno" ; then
|
||||||
echo inet_pton >> $crypto_p_sym
|
echo inet_pton >> $crypto_p_sym
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user