diff options
author | Brent Cook <bcook@openbsd.org> | 2017-04-28 00:22:43 -0500 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2017-04-28 00:22:43 -0500 |
commit | 53fb56ea87be14453c366fa63fc3296ef0a3ebac (patch) | |
tree | 6b212cf96147af5f9e3724cfdefb33e2fa14cdd8 /crypto | |
parent | 7ec0510e33ed897b2d6421a6235c563f1953e210 (diff) | |
parent | 048625cf2b36a91bcf04c5a1adc02fc5803491ca (diff) | |
download | portable-53fb56ea87be14453c366fa63fc3296ef0a3ebac.tar.gz portable-53fb56ea87be14453c366fa63fc3296ef0a3ebac.tar.bz2 portable-53fb56ea87be14453c366fa63fc3296ef0a3ebac.zip |
Land #306, add freezero
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/CMakeLists.txt | 5 | ||||
-rw-r--r-- | crypto/Makefile.am | 4 | ||||
-rw-r--r-- | crypto/compat/freezero.c | 13 |
3 files changed, 22 insertions, 0 deletions
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) |
682 | endif() | 682 | endif() |
683 | 683 | ||
684 | if(NOT HAVE_FREEZERO) | ||
685 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/freezero.c) | ||
686 | set(EXTRA_EXPORT ${EXTRA_EXPORT} freezero) | ||
687 | endif() | ||
688 | |||
684 | if(NOT HAVE_GETPAGESIZE) | 689 | if(NOT HAVE_GETPAGESIZE) |
685 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c) | 690 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c) |
686 | endif() | 691 | endif() |
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 | |||
84 | libcompat_la_SOURCES += compat/bsd-asprintf.c | 84 | libcompat_la_SOURCES += compat/bsd-asprintf.c |
85 | endif | 85 | endif |
86 | 86 | ||
87 | if !HAVE_FREEZERO | ||
88 | libcompat_la_SOURCES += compat/freezero.c | ||
89 | endif | ||
90 | |||
87 | if !HAVE_GETPAGESIZE | 91 | if !HAVE_GETPAGESIZE |
88 | libcompat_la_SOURCES += compat/getpagesize.c | 92 | libcompat_la_SOURCES += compat/getpagesize.c |
89 | endif | 93 | endif |
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 | |||
4 | void | ||
5 | freezero(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 | } | ||