aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorBrent Cook <bcook@openbsd.org>2014-10-29 15:44:36 -0500
committerBrent Cook <bcook@openbsd.org>2014-10-30 19:15:11 -0500
commita4cc953911a745d6e769a03cbe6442ee2fc27cbd (patch)
tree8c26006db95beb6249b755e108ee1aa317e742bd /crypto
parent727bccd093eaeac853ac84c7b6f31e67e452cde9 (diff)
downloadportable-a4cc953911a745d6e769a03cbe6442ee2fc27cbd.tar.gz
portable-a4cc953911a745d6e769a03cbe6442ee2fc27cbd.tar.bz2
portable-a4cc953911a745d6e769a03cbe6442ee2fc27cbd.zip
Improve and simplify function and header detection logic.
Simplify autoconf checks by using AC_CHECK_FUNCS/HEADERS. Clarify some ambiguous dependencies around strnlen/strndup. Unconditionally enable pidwraptest for all arc4random implementations. Remove HAVE_VASPRINTF conditional, since asprintf requires vasprintf. ok @doug
Diffstat (limited to 'crypto')
-rw-r--r--crypto/Makefile.am.tpl25
-rw-r--r--crypto/compat/bsd-asprintf.c4
2 files changed, 14 insertions, 15 deletions
diff --git a/crypto/Makefile.am.tpl b/crypto/Makefile.am.tpl
index 04ff7f7..0ace78a 100644
--- a/crypto/Makefile.am.tpl
+++ b/crypto/Makefile.am.tpl
@@ -16,7 +16,7 @@ noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la
16libcompatnoopt_la_CFLAGS = -O0 16libcompatnoopt_la_CFLAGS = -O0
17libcompatnoopt_la_SOURCES = 17libcompatnoopt_la_SOURCES =
18 18
19if NO_EXPLICIT_BZERO 19if !HAVE_EXPLICIT_BZERO
20libcompatnoopt_la_SOURCES += compat/explicit_bzero.c 20libcompatnoopt_la_SOURCES += compat/explicit_bzero.c
21endif 21endif
22 22
@@ -25,41 +25,42 @@ libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
25libcompat_la_SOURCES = 25libcompat_la_SOURCES =
26libcompat_la_LIBADD = $(PLATFORM_LDADD) 26libcompat_la_LIBADD = $(PLATFORM_LDADD)
27 27
28if NO_STRLCAT 28if !HAVE_STRLCAT
29libcompat_la_SOURCES += compat/strlcat.c 29libcompat_la_SOURCES += compat/strlcat.c
30endif 30endif
31 31
32if NO_STRLCPY 32if !HAVE_STRLCPY
33libcompat_la_SOURCES += compat/strlcpy.c 33libcompat_la_SOURCES += compat/strlcpy.c
34endif 34endif
35 35
36if NO_STRNDUP 36if !HAVE_STRNDUP
37libcompat_la_SOURCES += compat/strndup.c 37libcompat_la_SOURCES += compat/strndup.c
38if NO_STRNLEN 38# the only user of strnlen is strndup, so only build it if needed
39if !HAVE_STRNLEN
39libcompat_la_SOURCES += compat/strnlen.c 40libcompat_la_SOURCES += compat/strnlen.c
40endif 41endif
41endif 42endif
42 43
43if NO_ASPRINTF 44if !HAVE_ASPRINTF
44libcompat_la_SOURCES += compat/bsd-asprintf.c 45libcompat_la_SOURCES += compat/bsd-asprintf.c
45endif 46endif
46 47
47if NO_REALLOCARRAY 48if !HAVE_REALLOCARRAY
48libcompat_la_SOURCES += compat/reallocarray.c 49libcompat_la_SOURCES += compat/reallocarray.c
49endif 50endif
50 51
51if NO_TIMINGSAFE_MEMCMP 52if !HAVE_TIMINGSAFE_MEMCMP
52libcompat_la_SOURCES += compat/timingsafe_memcmp.c 53libcompat_la_SOURCES += compat/timingsafe_memcmp.c
53endif 54endif
54 55
55if NO_TIMINGSAFE_BCMP 56if !HAVE_TIMINGSAFE_BCMP
56libcompat_la_SOURCES += compat/timingsafe_bcmp.c 57libcompat_la_SOURCES += compat/timingsafe_bcmp.c
57endif 58endif
58 59
59if NO_ARC4RANDOM_BUF 60if !HAVE_ARC4RANDOM_BUF
60libcompat_la_SOURCES += compat/arc4random.c 61libcompat_la_SOURCES += compat/arc4random.c
61 62
62if NO_GETENTROPY 63if !HAVE_GETENTROPY
63if HOST_LINUX 64if HOST_LINUX
64libcompat_la_SOURCES += compat/getentropy_linux.c 65libcompat_la_SOURCES += compat/getentropy_linux.c
65endif 66endif
@@ -76,7 +77,7 @@ endif
76 77
77endif 78endif
78 79
79if NO_ISSETUGID 80if !HAVE_ISSETUGID
80if HOST_LINUX 81if HOST_LINUX
81libcompat_la_SOURCES += compat/issetugid_linux.c 82libcompat_la_SOURCES += compat/issetugid_linux.c
82endif 83endif
diff --git a/crypto/compat/bsd-asprintf.c b/crypto/compat/bsd-asprintf.c
index 8ccfa22..3728bc5 100644
--- a/crypto/compat/bsd-asprintf.c
+++ b/crypto/compat/bsd-asprintf.c
@@ -17,7 +17,7 @@
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */ 18 */
19 19
20#ifndef HAVE_VASPRINTF 20#ifndef HAVE_ASPRINTF
21 21
22#include <errno.h> 22#include <errno.h>
23#include <limits.h> /* for INT_MAX */ 23#include <limits.h> /* for INT_MAX */
@@ -80,9 +80,7 @@ fail:
80 errno = ENOMEM; 80 errno = ENOMEM;
81 return (-1); 81 return (-1);
82} 82}
83#endif
84 83
85#ifndef HAVE_ASPRINTF
86int asprintf(char **str, const char *fmt, ...) 84int asprintf(char **str, const char *fmt, ...)
87{ 85{
88 va_list ap; 86 va_list ap;