Add recallocarray

This commit is contained in:
kinichiro 2017-03-09 22:49:04 +09:00
parent 27f0879030
commit 8877e9bc55
5 changed files with 20 additions and 1 deletions

View File

@ -691,6 +691,11 @@ if(NOT HAVE_REALLOCARRAY)
set(EXTRA_EXPORT ${EXTRA_EXPORT} reallocarray)
endif()
if(NOT HAVE_RECALLOCARRAY)
set(CRYPTO_SRC ${CRYPTO_SRC} compat/recallocarray.c)
set(EXTRA_EXPORT ${EXTRA_EXPORT} recallocarray)
endif()
if(NOT HAVE_STRCASECMP)
set(CRYPTO_SRC ${CRYPTO_SRC} compat/strcasecmp.c)
set(EXTRA_EXPORT ${EXTRA_EXPORT} strcasecmp)

View File

@ -93,6 +93,10 @@ if !HAVE_REALLOCARRAY
libcompat_la_SOURCES += compat/reallocarray.c
endif
if !HAVE_RECALLOCARRAY
libcompat_la_SOURCES += compat/recallocarray.c
endif
if !HAVE_TIMINGSAFE_MEMCMP
libcompat_la_SOURCES += compat/timingsafe_memcmp.c
endif

View File

@ -29,6 +29,10 @@ uint32_t arc4random_uniform(uint32_t upper_bound);
void *reallocarray(void *, size_t, size_t);
#endif
#ifndef HAVE_RECALLOCARRAY
void *recallocarray(void *, size_t, size_t, size_t);
#endif
#ifndef HAVE_STRTONUM
long long strtonum(const char *nptr, long long minval,
long long maxval, const char **errstr);

View File

@ -3,7 +3,8 @@ AC_DEFUN([CHECK_LIBC_COMPAT], [
AC_CHECK_HEADERS([err.h readpassphrase.h])
# Check for general libc functions
AC_CHECK_FUNCS([asprintf 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])
AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
AM_CONDITIONAL([HAVE_INET_NTOP], [test "x$ac_cv_func_inet_ntop" = xyes])
@ -11,6 +12,7 @@ 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_READPASSPHRASE], [test "x$ac_cv_func_readpassphrase" = 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_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes])
AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes])
@ -177,6 +179,9 @@ fi
if test "x$ac_cv_func_reallocarray" = "xno" ; then
echo reallocarray >> $crypto_p_sym
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
echo strlcat >> $crypto_p_sym
fi

View File

@ -78,6 +78,7 @@ for i in crypto/compat libtls-standalone/compat; do
$libc_src/crypt/chacha_private.h \
$libc_src/net/inet_pton.c \
$libc_src/stdlib/reallocarray.c \
$libc_src/stdlib/recallocarray.c \
$libc_src/string/explicit_bzero.c \
$libc_src/string/strcasecmp.c \
$libc_src/string/strlcpy.c \