diff options
| author | Brent Cook <bcook@openbsd.org> | 2017-03-16 19:23:36 -0500 |
|---|---|---|
| committer | Brent Cook <bcook@openbsd.org> | 2017-03-16 19:23:36 -0500 |
| commit | d5b247cc4fe0f3dd6cc4f7084af7f290ba41e669 (patch) | |
| tree | ecff511a1a175c88222a9c83872920d512671717 | |
| parent | 8f69fe98dba08e22dd1341cbaad91745c8bf7ad7 (diff) | |
| parent | c61c9821e8417243a5a0cf691415f5e5626f2b3b (diff) | |
| download | portable-d5b247cc4fe0f3dd6cc4f7084af7f290ba41e669.tar.gz portable-d5b247cc4fe0f3dd6cc4f7084af7f290ba41e669.tar.bz2 portable-d5b247cc4fe0f3dd6cc4f7084af7f290ba41e669.zip | |
Land #297, Add recallocarray
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | crypto/CMakeLists.txt | 9 | ||||
| -rw-r--r-- | crypto/Makefile.am | 8 | ||||
| -rw-r--r-- | crypto/compat/getpagesize.c | 18 | ||||
| -rw-r--r-- | include/compat/stdlib.h | 4 | ||||
| -rw-r--r-- | include/compat/unistd.h | 4 | ||||
| -rw-r--r-- | m4/check-libc.m4 | 10 | ||||
| -rwxr-xr-x | update.sh | 1 |
8 files changed, 53 insertions, 2 deletions
| @@ -142,6 +142,7 @@ include/openssl/*.h | |||
| 142 | !/crypto/compat/arc4random.h | 142 | !/crypto/compat/arc4random.h |
| 143 | !/crypto/compat/b_win.c | 143 | !/crypto/compat/b_win.c |
| 144 | !/crypto/compat/explicit_bzero_win.c | 144 | !/crypto/compat/explicit_bzero_win.c |
| 145 | !/crypto/compat/getpagesize.c | ||
| 145 | !/crypto/compat/posix_win.c | 146 | !/crypto/compat/posix_win.c |
| 146 | !/crypto/compat/bsd_asprintf.c | 147 | !/crypto/compat/bsd_asprintf.c |
| 147 | !/crypto/compat/inet_pton.c | 148 | !/crypto/compat/inet_pton.c |
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 47f0077..d7b65e2 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt | |||
| @@ -681,6 +681,10 @@ 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_GETPAGESIZE) | ||
| 685 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c) | ||
| 686 | endif() | ||
| 687 | |||
| 684 | if(NOT HAVE_INET_PTON) | 688 | if(NOT HAVE_INET_PTON) |
| 685 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/inet_pton.c) | 689 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/inet_pton.c) |
| 686 | set(EXTRA_EXPORT ${EXTRA_EXPORT} inet_pton) | 690 | set(EXTRA_EXPORT ${EXTRA_EXPORT} inet_pton) |
| @@ -691,6 +695,11 @@ if(NOT HAVE_REALLOCARRAY) | |||
| 691 | set(EXTRA_EXPORT ${EXTRA_EXPORT} reallocarray) | 695 | set(EXTRA_EXPORT ${EXTRA_EXPORT} reallocarray) |
| 692 | endif() | 696 | endif() |
| 693 | 697 | ||
| 698 | if(NOT HAVE_RECALLOCARRAY) | ||
| 699 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/recallocarray.c) | ||
| 700 | set(EXTRA_EXPORT ${EXTRA_EXPORT} recallocarray) | ||
| 701 | endif() | ||
| 702 | |||
| 694 | if(NOT HAVE_STRCASECMP) | 703 | if(NOT HAVE_STRCASECMP) |
| 695 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/strcasecmp.c) | 704 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/strcasecmp.c) |
| 696 | set(EXTRA_EXPORT ${EXTRA_EXPORT} strcasecmp) | 705 | set(EXTRA_EXPORT ${EXTRA_EXPORT} strcasecmp) |
diff --git a/crypto/Makefile.am b/crypto/Makefile.am index 23aaeac..dc94a8c 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am | |||
| @@ -81,6 +81,10 @@ if !HAVE_ASPRINTF | |||
| 81 | libcompat_la_SOURCES += compat/bsd-asprintf.c | 81 | libcompat_la_SOURCES += compat/bsd-asprintf.c |
| 82 | endif | 82 | endif |
| 83 | 83 | ||
| 84 | if !HAVE_GETPAGESIZE | ||
| 85 | libcompat_la_SOURCES += compat/getpagesize.c | ||
| 86 | endif | ||
| 87 | |||
| 84 | if !HAVE_INET_PTON | 88 | if !HAVE_INET_PTON |
| 85 | libcompat_la_SOURCES += compat/inet_pton.c | 89 | libcompat_la_SOURCES += compat/inet_pton.c |
| 86 | endif | 90 | endif |
| @@ -93,6 +97,10 @@ if !HAVE_REALLOCARRAY | |||
| 93 | libcompat_la_SOURCES += compat/reallocarray.c | 97 | libcompat_la_SOURCES += compat/reallocarray.c |
| 94 | endif | 98 | endif |
| 95 | 99 | ||
| 100 | if !HAVE_RECALLOCARRAY | ||
| 101 | libcompat_la_SOURCES += compat/recallocarray.c | ||
| 102 | endif | ||
| 103 | |||
| 96 | if !HAVE_TIMINGSAFE_MEMCMP | 104 | if !HAVE_TIMINGSAFE_MEMCMP |
| 97 | libcompat_la_SOURCES += compat/timingsafe_memcmp.c | 105 | libcompat_la_SOURCES += compat/timingsafe_memcmp.c |
| 98 | endif | 106 | endif |
diff --git a/crypto/compat/getpagesize.c b/crypto/compat/getpagesize.c new file mode 100644 index 0000000..098efa9 --- /dev/null +++ b/crypto/compat/getpagesize.c | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | /* $OpenBSD$ */ | ||
| 2 | |||
| 3 | #include <unistd.h> | ||
| 4 | |||
| 5 | #ifdef _MSC_VER | ||
| 6 | #include <windows.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | int | ||
| 10 | getpagesize(void) { | ||
| 11 | #ifdef _MSC_VER | ||
| 12 | SYSTEM_INFO system_info; | ||
| 13 | GetSystemInfo(&system_info); | ||
| 14 | return system_info.dwPageSize; | ||
| 15 | #else | ||
| 16 | return sysconf(_SC_PAGESIZE); | ||
| 17 | #endif | ||
| 18 | } | ||
diff --git a/include/compat/stdlib.h b/include/compat/stdlib.h index 781be77..11f82ba 100644 --- a/include/compat/stdlib.h +++ b/include/compat/stdlib.h | |||
| @@ -29,6 +29,10 @@ uint32_t arc4random_uniform(uint32_t upper_bound); | |||
| 29 | void *reallocarray(void *, size_t, size_t); | 29 | void *reallocarray(void *, size_t, size_t); |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #ifndef HAVE_RECALLOCARRAY | ||
| 33 | void *recallocarray(void *, size_t, size_t, size_t); | ||
| 34 | #endif | ||
| 35 | |||
| 32 | #ifndef HAVE_STRTONUM | 36 | #ifndef HAVE_STRTONUM |
| 33 | long long strtonum(const char *nptr, long long minval, | 37 | long long strtonum(const char *nptr, long long minval, |
| 34 | long long maxval, const char **errstr); | 38 | long long maxval, const char **errstr); |
diff --git a/include/compat/unistd.h b/include/compat/unistd.h index b37a2f6..d596043 100644 --- a/include/compat/unistd.h +++ b/include/compat/unistd.h | |||
| @@ -39,6 +39,10 @@ int getentropy(void *buf, size_t buflen); | |||
| 39 | #endif | 39 | #endif |
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 42 | #ifndef HAVE_GETPAGESIZE | ||
| 43 | int getpagesize(void); | ||
| 44 | #endif | ||
| 45 | |||
| 42 | #define pledge(request, paths) 0 | 46 | #define pledge(request, paths) 0 |
| 43 | 47 | ||
| 44 | #ifndef HAVE_PIPE2 | 48 | #ifndef HAVE_PIPE2 |
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4 index 53ffce6..f9ddf73 100644 --- a/m4/check-libc.m4 +++ b/m4/check-libc.m4 | |||
| @@ -2,15 +2,18 @@ AC_DEFUN([CHECK_LIBC_COMPAT], [ | |||
| 2 | # Check for libc headers | 2 | # Check for libc headers |
| 3 | AC_CHECK_HEADERS([err.h readpassphrase.h]) | 3 | AC_CHECK_HEADERS([err.h readpassphrase.h]) |
| 4 | # Check for general libc functions | 4 | # Check for general libc functions |
| 5 | AC_CHECK_FUNCS([asprintf inet_ntop inet_pton memmem readpassphrase]) | 5 | AC_CHECK_FUNCS([asprintf getpagesize inet_ntop inet_pton memmem readpassphrase]) |
| 6 | AC_CHECK_FUNCS([reallocarray strlcat strlcpy strndup strnlen strsep strtonum]) | 6 | AC_CHECK_FUNCS([reallocarray recallocarray]) |
| 7 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) | ||
| 7 | AC_CHECK_FUNCS([timegm _mkgmtime]) | 8 | AC_CHECK_FUNCS([timegm _mkgmtime]) |
| 8 | AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) | 9 | AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) |
| 10 | AM_CONDITIONAL([HAVE_GETPAGESIZE], [test "x$ac_cv_func_getpagesize" = xyes]) | ||
| 9 | AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes]) | 11 | AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes]) |
| 10 | AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes]) | 12 | AM_CONDITIONAL([HAVE_INET_PTON], [test "x$ac_cv_func_inet_pton" = xyes]) |
| 11 | AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) | 13 | AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) |
| 12 | AM_CONDITIONAL([HAVE_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = xyes]) | 14 | AM_CONDITIONAL([HAVE_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = xyes]) |
| 13 | AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) | 15 | AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) |
| 16 | AM_CONDITIONAL([HAVE_RECALLOCARRAY], [test "x$ac_cv_func_recallocarray" = xyes]) | ||
| 14 | AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes]) | 17 | AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes]) |
| 15 | AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes]) | 18 | AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes]) |
| 16 | AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes]) | 19 | AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes]) |
| @@ -173,6 +176,9 @@ fi | |||
| 173 | if test "x$ac_cv_func_reallocarray" = "xno" ; then | 176 | if test "x$ac_cv_func_reallocarray" = "xno" ; then |
| 174 | echo reallocarray >> $crypto_p_sym | 177 | echo reallocarray >> $crypto_p_sym |
| 175 | fi | 178 | fi |
| 179 | if test "x$ac_cv_func_recallocarray" = "xno" ; then | ||
| 180 | echo recallocarray >> $crypto_p_sym | ||
| 181 | fi | ||
| 176 | if test "x$ac_cv_func_strlcat" = "xno" ; then | 182 | if test "x$ac_cv_func_strlcat" = "xno" ; then |
| 177 | echo strlcat >> $crypto_p_sym | 183 | echo strlcat >> $crypto_p_sym |
| 178 | fi | 184 | fi |
| @@ -78,6 +78,7 @@ for i in crypto/compat libtls-standalone/compat; do | |||
| 78 | $libc_src/crypt/chacha_private.h \ | 78 | $libc_src/crypt/chacha_private.h \ |
| 79 | $libc_src/net/inet_pton.c \ | 79 | $libc_src/net/inet_pton.c \ |
| 80 | $libc_src/stdlib/reallocarray.c \ | 80 | $libc_src/stdlib/reallocarray.c \ |
| 81 | $libc_src/stdlib/recallocarray.c \ | ||
| 81 | $libc_src/string/explicit_bzero.c \ | 82 | $libc_src/string/explicit_bzero.c \ |
| 82 | $libc_src/string/strcasecmp.c \ | 83 | $libc_src/string/strcasecmp.c \ |
| 83 | $libc_src/string/strlcpy.c \ | 84 | $libc_src/string/strlcpy.c \ |
