add strndup/strnlen compat functions from OpenBSD

This commit is contained in:
Brent Cook 2014-07-27 06:11:56 -05:00
parent fb67b92eb2
commit 0a74a4d464
5 changed files with 17 additions and 1 deletions

2
.gitignore vendored
View File

@ -108,6 +108,8 @@ crypto/compat/getentropy_*.c
crypto/compat/reallocarray.c crypto/compat/reallocarray.c
crypto/compat/strlcat.c crypto/compat/strlcat.c
crypto/compat/strlcpy.c crypto/compat/strlcpy.c
crypto/compat/strndup.c
crypto/compat/strnlen.c
crypto/compat/strtonum.c crypto/compat/strtonum.c
crypto/compat/timingsafe_bcmp.c crypto/compat/timingsafe_bcmp.c
crypto/compat/timingsafe_memcmp.c crypto/compat/timingsafe_memcmp.c

View File

@ -64,6 +64,11 @@ AC_CHECK_FUNC(strlcat,[AC_SEARCH_LIBS(strlcat,, [NO_STRLCAT=],
AC_SUBST(NO_STRLCAT) AC_SUBST(NO_STRLCAT)
AM_CONDITIONAL(NO_STRLCAT, test "x$NO_STRLCAT" = "xyes") AM_CONDITIONAL(NO_STRLCAT, test "x$NO_STRLCAT" = "xyes")
AC_CHECK_FUNC(strndup,[AC_SEARCH_LIBS(strndup,, [NO_STRNDUP=],
[NO_STRNDUP=yes])], [NO_STRNDUP=yes])
AC_SUBST(NO_STRNDUP)
AM_CONDITIONAL(NO_STRNDUP, test "x$NO_STRNDUP" = "xyes")
AC_CHECK_FUNC(reallocarray,[AC_SEARCH_LIBS(reallocarray,, [NO_REALLOCARRAY=], AC_CHECK_FUNC(reallocarray,[AC_SEARCH_LIBS(reallocarray,, [NO_REALLOCARRAY=],
[NO_REALLOCARRAY=yes])], [NO_REALLOCARRAY=yes]) [NO_REALLOCARRAY=yes])], [NO_REALLOCARRAY=yes])
AC_SUBST(NO_REALLOCARRAY) AC_SUBST(NO_REALLOCARRAY)

View File

@ -33,6 +33,11 @@ if NO_STRLCPY
libcompat_la_SOURCES += compat/strlcpy.c libcompat_la_SOURCES += compat/strlcpy.c
endif endif
if NO_STRNDUP
libcompat_la_SOURCES += compat/strndup.c
libcompat_la_SOURCES += compat/strnlen.c
endif
if NO_REALLOCARRAY if NO_REALLOCARRAY
libcompat_la_SOURCES += compat/reallocarray.c libcompat_la_SOURCES += compat/reallocarray.c
endif endif

View File

@ -16,6 +16,10 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz); size_t strlcat(char *dst, const char *src, size_t siz);
char * strndup(const char *str, size_t maxlen);
size_t strnlen(const char *str, size_t maxlen);
void explicit_bzero(void *, size_t); void explicit_bzero(void *, size_t);
int timingsafe_bcmp(const void *b1, const void *b2, size_t n); int timingsafe_bcmp(const void *b1, const void *b2, size_t n);

View File

@ -64,7 +64,7 @@ $CP $libssl_src/src/crypto/opensslfeatures.h include/openssl
$CP $libssl_src/src/e_os2.h include/openssl $CP $libssl_src/src/e_os2.h include/openssl
$CP $libssl_src/src/ssl/pqueue.h include $CP $libssl_src/src/ssl/pqueue.h include
for i in explicit_bzero.c strlcpy.c strlcat.c timingsafe_bcmp.c timingsafe_memcmp.c; do for i in explicit_bzero.c strlcpy.c strlcat.c strndup.c strnlen.c timingsafe_bcmp.c timingsafe_memcmp.c; do
$CP $libc_src/string/$i crypto/compat $CP $libc_src/string/$i crypto/compat
done done
$CP $libc_src/stdlib/reallocarray.c crypto/compat $CP $libc_src/stdlib/reallocarray.c crypto/compat