Land #297, Add recallocarray
This commit is contained in:
commit
d5b247cc4f
1
.gitignore
vendored
1
.gitignore
vendored
@ -142,6 +142,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/getpagesize.c
|
||||||
!/crypto/compat/posix_win.c
|
!/crypto/compat/posix_win.c
|
||||||
!/crypto/compat/bsd_asprintf.c
|
!/crypto/compat/bsd_asprintf.c
|
||||||
!/crypto/compat/inet_pton.c
|
!/crypto/compat/inet_pton.c
|
||||||
|
@ -681,6 +681,10 @@ if(NOT HAVE_ASPRINTF)
|
|||||||
set(EXTRA_EXPORT ${EXTRA_EXPORT} vasprintf)
|
set(EXTRA_EXPORT ${EXTRA_EXPORT} vasprintf)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT HAVE_GETPAGESIZE)
|
||||||
|
set(CRYPTO_SRC ${CRYPTO_SRC} compat/getpagesize.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT HAVE_INET_PTON)
|
if(NOT HAVE_INET_PTON)
|
||||||
set(CRYPTO_SRC ${CRYPTO_SRC} compat/inet_pton.c)
|
set(CRYPTO_SRC ${CRYPTO_SRC} compat/inet_pton.c)
|
||||||
set(EXTRA_EXPORT ${EXTRA_EXPORT} inet_pton)
|
set(EXTRA_EXPORT ${EXTRA_EXPORT} inet_pton)
|
||||||
@ -691,6 +695,11 @@ if(NOT HAVE_REALLOCARRAY)
|
|||||||
set(EXTRA_EXPORT ${EXTRA_EXPORT} reallocarray)
|
set(EXTRA_EXPORT ${EXTRA_EXPORT} reallocarray)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT HAVE_RECALLOCARRAY)
|
||||||
|
set(CRYPTO_SRC ${CRYPTO_SRC} compat/recallocarray.c)
|
||||||
|
set(EXTRA_EXPORT ${EXTRA_EXPORT} recallocarray)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT HAVE_STRCASECMP)
|
if(NOT HAVE_STRCASECMP)
|
||||||
set(CRYPTO_SRC ${CRYPTO_SRC} compat/strcasecmp.c)
|
set(CRYPTO_SRC ${CRYPTO_SRC} compat/strcasecmp.c)
|
||||||
set(EXTRA_EXPORT ${EXTRA_EXPORT} strcasecmp)
|
set(EXTRA_EXPORT ${EXTRA_EXPORT} strcasecmp)
|
||||||
|
@ -81,6 +81,10 @@ if !HAVE_ASPRINTF
|
|||||||
libcompat_la_SOURCES += compat/bsd-asprintf.c
|
libcompat_la_SOURCES += compat/bsd-asprintf.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !HAVE_GETPAGESIZE
|
||||||
|
libcompat_la_SOURCES += compat/getpagesize.c
|
||||||
|
endif
|
||||||
|
|
||||||
if !HAVE_INET_PTON
|
if !HAVE_INET_PTON
|
||||||
libcompat_la_SOURCES += compat/inet_pton.c
|
libcompat_la_SOURCES += compat/inet_pton.c
|
||||||
endif
|
endif
|
||||||
@ -93,6 +97,10 @@ if !HAVE_REALLOCARRAY
|
|||||||
libcompat_la_SOURCES += compat/reallocarray.c
|
libcompat_la_SOURCES += compat/reallocarray.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !HAVE_RECALLOCARRAY
|
||||||
|
libcompat_la_SOURCES += compat/recallocarray.c
|
||||||
|
endif
|
||||||
|
|
||||||
if !HAVE_TIMINGSAFE_MEMCMP
|
if !HAVE_TIMINGSAFE_MEMCMP
|
||||||
libcompat_la_SOURCES += compat/timingsafe_memcmp.c
|
libcompat_la_SOURCES += compat/timingsafe_memcmp.c
|
||||||
endif
|
endif
|
||||||
|
18
crypto/compat/getpagesize.c
Normal file
18
crypto/compat/getpagesize.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
getpagesize(void) {
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
SYSTEM_INFO system_info;
|
||||||
|
GetSystemInfo(&system_info);
|
||||||
|
return system_info.dwPageSize;
|
||||||
|
#else
|
||||||
|
return sysconf(_SC_PAGESIZE);
|
||||||
|
#endif
|
||||||
|
}
|
@ -29,6 +29,10 @@ uint32_t arc4random_uniform(uint32_t upper_bound);
|
|||||||
void *reallocarray(void *, size_t, size_t);
|
void *reallocarray(void *, size_t, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_RECALLOCARRAY
|
||||||
|
void *recallocarray(void *, size_t, size_t, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRTONUM
|
#ifndef HAVE_STRTONUM
|
||||||
long long strtonum(const char *nptr, long long minval,
|
long long strtonum(const char *nptr, long long minval,
|
||||||
long long maxval, const char **errstr);
|
long long maxval, const char **errstr);
|
||||||
|
@ -39,6 +39,10 @@ int getentropy(void *buf, size_t buflen);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETPAGESIZE
|
||||||
|
int getpagesize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define pledge(request, paths) 0
|
#define pledge(request, paths) 0
|
||||||
|
|
||||||
#ifndef HAVE_PIPE2
|
#ifndef HAVE_PIPE2
|
||||||
|
@ -2,15 +2,18 @@ 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 inet_ntop inet_pton memmem readpassphrase])
|
AC_CHECK_FUNCS([asprintf getpagesize inet_ntop inet_pton memmem readpassphrase])
|
||||||
AC_CHECK_FUNCS([reallocarray strlcat strlcpy strndup strnlen strsep strtonum])
|
AC_CHECK_FUNCS([reallocarray recallocarray])
|
||||||
|
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_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])
|
||||||
AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
|
AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
|
||||||
AM_CONDITIONAL([HAVE_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = xyes])
|
AM_CONDITIONAL([HAVE_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = xyes])
|
||||||
AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])
|
AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])
|
||||||
|
AM_CONDITIONAL([HAVE_RECALLOCARRAY], [test "x$ac_cv_func_recallocarray" = xyes])
|
||||||
AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes])
|
AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes])
|
||||||
AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes])
|
AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes])
|
||||||
AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes])
|
AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes])
|
||||||
@ -173,6 +176,9 @@ fi
|
|||||||
if test "x$ac_cv_func_reallocarray" = "xno" ; then
|
if test "x$ac_cv_func_reallocarray" = "xno" ; then
|
||||||
echo reallocarray >> $crypto_p_sym
|
echo reallocarray >> $crypto_p_sym
|
||||||
fi
|
fi
|
||||||
|
if test "x$ac_cv_func_recallocarray" = "xno" ; then
|
||||||
|
echo recallocarray >> $crypto_p_sym
|
||||||
|
fi
|
||||||
if test "x$ac_cv_func_strlcat" = "xno" ; then
|
if test "x$ac_cv_func_strlcat" = "xno" ; then
|
||||||
echo strlcat >> $crypto_p_sym
|
echo strlcat >> $crypto_p_sym
|
||||||
fi
|
fi
|
||||||
|
@ -78,6 +78,7 @@ for i in crypto/compat libtls-standalone/compat; do
|
|||||||
$libc_src/crypt/chacha_private.h \
|
$libc_src/crypt/chacha_private.h \
|
||||||
$libc_src/net/inet_pton.c \
|
$libc_src/net/inet_pton.c \
|
||||||
$libc_src/stdlib/reallocarray.c \
|
$libc_src/stdlib/reallocarray.c \
|
||||||
|
$libc_src/stdlib/recallocarray.c \
|
||||||
$libc_src/string/explicit_bzero.c \
|
$libc_src/string/explicit_bzero.c \
|
||||||
$libc_src/string/strcasecmp.c \
|
$libc_src/string/strcasecmp.c \
|
||||||
$libc_src/string/strlcpy.c \
|
$libc_src/string/strlcpy.c \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user