diff options
| author | Brent Cook <bcook@openbsd.org> | 2014-07-27 06:11:56 -0500 |
|---|---|---|
| committer | Brent Cook <bcook@openbsd.org> | 2014-07-28 07:07:23 -0500 |
| commit | 0a74a4d4648f8655ad4862f28d995fcf2865b3b2 (patch) | |
| tree | e59f4c643104f98fe504604e590f458edbb8fd24 | |
| parent | fb67b92eb2bf94816facee5469a7015101b3a07e (diff) | |
| download | portable-0a74a4d4648f8655ad4862f28d995fcf2865b3b2.tar.gz portable-0a74a4d4648f8655ad4862f28d995fcf2865b3b2.tar.bz2 portable-0a74a4d4648f8655ad4862f28d995fcf2865b3b2.zip | |
add strndup/strnlen compat functions from OpenBSD
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | configure.ac.tpl | 5 | ||||
| -rw-r--r-- | crypto/Makefile.am.tpl | 5 | ||||
| -rw-r--r-- | include/string.h | 4 | ||||
| -rwxr-xr-x | update.sh | 2 |
5 files changed, 17 insertions, 1 deletions
| @@ -108,6 +108,8 @@ crypto/compat/getentropy_*.c | |||
| 108 | crypto/compat/reallocarray.c | 108 | crypto/compat/reallocarray.c |
| 109 | crypto/compat/strlcat.c | 109 | crypto/compat/strlcat.c |
| 110 | crypto/compat/strlcpy.c | 110 | crypto/compat/strlcpy.c |
| 111 | crypto/compat/strndup.c | ||
| 112 | crypto/compat/strnlen.c | ||
| 111 | crypto/compat/strtonum.c | 113 | crypto/compat/strtonum.c |
| 112 | crypto/compat/timingsafe_bcmp.c | 114 | crypto/compat/timingsafe_bcmp.c |
| 113 | crypto/compat/timingsafe_memcmp.c | 115 | crypto/compat/timingsafe_memcmp.c |
diff --git a/configure.ac.tpl b/configure.ac.tpl index 8e85e9b..61476cf 100644 --- a/configure.ac.tpl +++ b/configure.ac.tpl | |||
| @@ -64,6 +64,11 @@ AC_CHECK_FUNC(strlcat,[AC_SEARCH_LIBS(strlcat,, [NO_STRLCAT=], | |||
| 64 | AC_SUBST(NO_STRLCAT) | 64 | AC_SUBST(NO_STRLCAT) |
| 65 | AM_CONDITIONAL(NO_STRLCAT, test "x$NO_STRLCAT" = "xyes") | 65 | AM_CONDITIONAL(NO_STRLCAT, test "x$NO_STRLCAT" = "xyes") |
| 66 | 66 | ||
| 67 | AC_CHECK_FUNC(strndup,[AC_SEARCH_LIBS(strndup,, [NO_STRNDUP=], | ||
| 68 | [NO_STRNDUP=yes])], [NO_STRNDUP=yes]) | ||
| 69 | AC_SUBST(NO_STRNDUP) | ||
| 70 | AM_CONDITIONAL(NO_STRNDUP, test "x$NO_STRNDUP" = "xyes") | ||
| 71 | |||
| 67 | AC_CHECK_FUNC(reallocarray,[AC_SEARCH_LIBS(reallocarray,, [NO_REALLOCARRAY=], | 72 | AC_CHECK_FUNC(reallocarray,[AC_SEARCH_LIBS(reallocarray,, [NO_REALLOCARRAY=], |
| 68 | [NO_REALLOCARRAY=yes])], [NO_REALLOCARRAY=yes]) | 73 | [NO_REALLOCARRAY=yes])], [NO_REALLOCARRAY=yes]) |
| 69 | AC_SUBST(NO_REALLOCARRAY) | 74 | AC_SUBST(NO_REALLOCARRAY) |
diff --git a/crypto/Makefile.am.tpl b/crypto/Makefile.am.tpl index a29e07f..6ac6c4f 100644 --- a/crypto/Makefile.am.tpl +++ b/crypto/Makefile.am.tpl | |||
| @@ -33,6 +33,11 @@ if NO_STRLCPY | |||
| 33 | libcompat_la_SOURCES += compat/strlcpy.c | 33 | libcompat_la_SOURCES += compat/strlcpy.c |
| 34 | endif | 34 | endif |
| 35 | 35 | ||
| 36 | if NO_STRNDUP | ||
| 37 | libcompat_la_SOURCES += compat/strndup.c | ||
| 38 | libcompat_la_SOURCES += compat/strnlen.c | ||
| 39 | endif | ||
| 40 | |||
| 36 | if NO_REALLOCARRAY | 41 | if NO_REALLOCARRAY |
| 37 | libcompat_la_SOURCES += compat/reallocarray.c | 42 | libcompat_la_SOURCES += compat/reallocarray.c |
| 38 | endif | 43 | endif |
diff --git a/include/string.h b/include/string.h index 6277247..cd3430a 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -16,6 +16,10 @@ size_t strlcpy(char *dst, const char *src, size_t siz); | |||
| 16 | 16 | ||
| 17 | size_t strlcat(char *dst, const char *src, size_t siz); | 17 | size_t strlcat(char *dst, const char *src, size_t siz); |
| 18 | 18 | ||
| 19 | char * strndup(const char *str, size_t maxlen); | ||
| 20 | |||
| 21 | size_t strnlen(const char *str, size_t maxlen); | ||
| 22 | |||
| 19 | void explicit_bzero(void *, size_t); | 23 | void explicit_bzero(void *, size_t); |
| 20 | 24 | ||
| 21 | int timingsafe_bcmp(const void *b1, const void *b2, size_t n); | 25 | int timingsafe_bcmp(const void *b1, const void *b2, size_t n); |
| @@ -64,7 +64,7 @@ $CP $libssl_src/src/crypto/opensslfeatures.h include/openssl | |||
| 64 | $CP $libssl_src/src/e_os2.h include/openssl | 64 | $CP $libssl_src/src/e_os2.h include/openssl |
| 65 | $CP $libssl_src/src/ssl/pqueue.h include | 65 | $CP $libssl_src/src/ssl/pqueue.h include |
| 66 | 66 | ||
| 67 | for i in explicit_bzero.c strlcpy.c strlcat.c timingsafe_bcmp.c timingsafe_memcmp.c; do | 67 | for i in explicit_bzero.c strlcpy.c strlcat.c strndup.c strnlen.c timingsafe_bcmp.c timingsafe_memcmp.c; do |
| 68 | $CP $libc_src/string/$i crypto/compat | 68 | $CP $libc_src/string/$i crypto/compat |
| 69 | done | 69 | done |
| 70 | $CP $libc_src/stdlib/reallocarray.c crypto/compat | 70 | $CP $libc_src/stdlib/reallocarray.c crypto/compat |
