aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--crypto/CMakeLists.txt5
-rw-r--r--crypto/Makefile.am4
-rw-r--r--crypto/compat/freezero.c13
-rw-r--r--include/compat/stdlib.h4
-rw-r--r--m4/check-libc.m48
6 files changed, 33 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 85bbe6e..f8b728c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -143,6 +143,7 @@ include/openssl/*.h
143!/crypto/compat/arc4random.h 143!/crypto/compat/arc4random.h
144!/crypto/compat/b_win.c 144!/crypto/compat/b_win.c
145!/crypto/compat/explicit_bzero_win.c 145!/crypto/compat/explicit_bzero_win.c
146!/crypto/compat/freezero.c
146!/crypto/compat/getpagesize.c 147!/crypto/compat/getpagesize.c
147!/crypto/compat/posix_win.c 148!/crypto/compat/posix_win.c
148!/crypto/compat/bsd_asprintf.c 149!/crypto/compat/bsd_asprintf.c
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index d7b65e2..028d840 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -681,6 +681,11 @@ if(NOT HAVE_ASPRINTF)
681 set(EXTRA_EXPORT ${EXTRA_EXPORT} vasprintf) 681 set(EXTRA_EXPORT ${EXTRA_EXPORT} vasprintf)
682endif() 682endif()
683 683
684if(NOT HAVE_FREEZERO)
685 set(CRYPTO_SRC ${CRYPTO_SRC} compat/freezero.c)
686 set(EXTRA_EXPORT ${EXTRA_EXPORT} freezero)
687endif()
688
684if(NOT HAVE_GETPAGESIZE) 689if(NOT HAVE_GETPAGESIZE)
685 set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c) 690 set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c)
686endif() 691endif()
diff --git a/crypto/Makefile.am b/crypto/Makefile.am
index 04b67aa..0e7f9c8 100644
--- a/crypto/Makefile.am
+++ b/crypto/Makefile.am
@@ -84,6 +84,10 @@ if !HAVE_ASPRINTF
84libcompat_la_SOURCES += compat/bsd-asprintf.c 84libcompat_la_SOURCES += compat/bsd-asprintf.c
85endif 85endif
86 86
87if !HAVE_FREEZERO
88libcompat_la_SOURCES += compat/freezero.c
89endif
90
87if !HAVE_GETPAGESIZE 91if !HAVE_GETPAGESIZE
88libcompat_la_SOURCES += compat/getpagesize.c 92libcompat_la_SOURCES += compat/getpagesize.c
89endif 93endif
diff --git a/crypto/compat/freezero.c b/crypto/compat/freezero.c
new file mode 100644
index 0000000..8becc00
--- /dev/null
+++ b/crypto/compat/freezero.c
@@ -0,0 +1,13 @@
1#include <string.h>
2#include <stdlib.h>
3
4void
5freezero(void *ptr, size_t sz)
6{
7 /* This is legal. */
8 if (ptr == NULL)
9 return;
10
11 explicit_bzero(ptr, sz);
12 free(ptr);
13}
diff --git a/include/compat/stdlib.h b/include/compat/stdlib.h
index 11f82ba..cc04856 100644
--- a/include/compat/stdlib.h
+++ b/include/compat/stdlib.h
@@ -25,6 +25,10 @@ void arc4random_buf(void *_buf, size_t n);
25uint32_t arc4random_uniform(uint32_t upper_bound); 25uint32_t arc4random_uniform(uint32_t upper_bound);
26#endif 26#endif
27 27
28#ifndef HAVE_FREEZERO
29void freezero(void *ptr, size_t sz);
30#endif
31
28#ifndef HAVE_REALLOCARRAY 32#ifndef HAVE_REALLOCARRAY
29void *reallocarray(void *, size_t, size_t); 33void *reallocarray(void *, size_t, size_t);
30#endif 34#endif
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4
index 066b394..d9b7b88 100644
--- a/m4/check-libc.m4
+++ b/m4/check-libc.m4
@@ -2,11 +2,12 @@ AC_DEFUN([CHECK_LIBC_COMPAT], [
2# Check for libc headers 2# Check for libc headers
3AC_CHECK_HEADERS([err.h readpassphrase.h]) 3AC_CHECK_HEADERS([err.h readpassphrase.h])
4# Check for general libc functions 4# Check for general libc functions
5AC_CHECK_FUNCS([asprintf getpagesize inet_ntop inet_pton memmem readpassphrase]) 5AC_CHECK_FUNCS([asprintf freezero getpagesize inet_ntop inet_pton memmem])
6AC_CHECK_FUNCS([reallocarray recallocarray]) 6AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray])
7AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) 7AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
8AC_CHECK_FUNCS([timegm _mkgmtime]) 8AC_CHECK_FUNCS([timegm _mkgmtime])
9AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) 9AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
10AM_CONDITIONAL([HAVE_FREEZERO], [test "x$ac_cv_func_freezero" = xyes])
10AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes]) 11AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes])
11AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes]) 12AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes])
12AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes]) 13AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes])
@@ -170,6 +171,9 @@ fi
170if test "x$ac_cv_func_explicit_bzero" = "xno" ; then 171if test "x$ac_cv_func_explicit_bzero" = "xno" ; then
171 echo explicit_bzero >> $crypto_p_sym 172 echo explicit_bzero >> $crypto_p_sym
172fi 173fi
174if test "x$ac_cv_func_freezero" = "xno" ; then
175 echo freezero >> $crypto_p_sym
176fi
173if test "x$ac_cv_func_inet_pton" = "xno" ; then 177if test "x$ac_cv_func_inet_pton" = "xno" ; then
174 echo inet_pton >> $crypto_p_sym 178 echo inet_pton >> $crypto_p_sym
175fi 179fi