From 8e20d628e89dce6d54a43653d15b7e30936fac0e Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 17 Sep 2018 07:06:57 +0000 Subject: [PATCH] - Fix compile on Mac for unbound, provide explicit_bzero when libc does not have it. git-svn-id: file:///svn/unbound/trunk@4907 be551aaa-1e26-0410-a405-d3ace91eadb9 --- config.h.in | 12 +++++++++++- configure | 23 +++++++++++++++++------ configure.ac | 8 ++++++-- doc/Changelog | 4 ++++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/config.h.in b/config.h.in index d187e0010..7ffb3c989 100644 --- a/config.h.in +++ b/config.h.in @@ -3,6 +3,9 @@ /* apply the noreturn attribute to a function that exits the program */ #undef ATTR_NORETURN +/* apply the weak attribute to a symbol */ +#undef ATTR_WEAK + /* Directory to chroot to */ #undef CHROOT_DIR @@ -205,6 +208,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_EXPAT_H +/* Define to 1 if you have the `explicit_bzero' function. */ +#undef HAVE_EXPLICIT_BZERO + /* Define to 1 if you have the `fcntl' function. */ #undef HAVE_FCNTL @@ -1150,6 +1156,11 @@ char *strsep(char **stringp, const char *delim); int isblank(int c); #endif +#ifndef HAVE_EXPLICIT_BZERO +#define explicit_bzero unbound_explicit_bzero +void explicit_bzero(void* buf, size_t len); +#endif + #if defined(HAVE_INET_NTOP) && !HAVE_DECL_INET_NTOP const char *inet_ntop(int af, const void *src, char *dst, size_t size); #endif @@ -1182,7 +1193,6 @@ void *reallocarray(void *ptr, size_t nmemb, size_t size); # endif #endif /* HAVE_LIBRESSL */ #ifndef HAVE_ARC4RANDOM -void explicit_bzero(void* buf, size_t len); int getentropy(void* buf, size_t len); uint32_t arc4random(void); void arc4random_buf(void* buf, size_t n); diff --git a/configure b/configure index 6666e4546..4f134fca0 100755 --- a/configure +++ b/configure @@ -6266,6 +6266,9 @@ if test $ac_cv_c_weak_attribute = yes; then $as_echo "#define HAVE_ATTR_WEAK 1" >>confdefs.h + +$as_echo "#define ATTR_WEAK __attribute__((weak))" >>confdefs.h + fi @@ -20079,6 +20082,20 @@ esac fi +ac_fn_c_check_func "$LINENO" "explicit_bzero" "ac_cv_func_explicit_bzero" +if test "x$ac_cv_func_explicit_bzero" = xyes; then : + $as_echo "#define HAVE_EXPLICIT_BZERO 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" explicit_bzero.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS explicit_bzero.$ac_objext" + ;; +esac + +fi + + LIBOBJ_WITHOUT_CTIMEARC4="$LIBOBJS" ac_fn_c_check_func "$LINENO" "reallocarray" "ac_cv_func_reallocarray" @@ -20125,12 +20142,6 @@ fi if test "$ac_cv_func_arc4random" = "no"; then - case " $LIBOBJS " in - *" explicit_bzero.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS explicit_bzero.$ac_objext" - ;; -esac - case " $LIBOBJS " in *" arc4_lock.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS arc4_lock.$ac_objext" diff --git a/configure.ac b/configure.ac index 449cf3266..772a1417a 100644 --- a/configure.ac +++ b/configure.ac @@ -1422,6 +1422,7 @@ AC_REPLACE_FUNCS(strlcpy) AC_REPLACE_FUNCS(memmove) AC_REPLACE_FUNCS(gmtime_r) AC_REPLACE_FUNCS(isblank) +AC_REPLACE_FUNCS(explicit_bzero) dnl without CTIME, ARC4-functions and without reallocarray. LIBOBJ_WITHOUT_CTIMEARC4="$LIBOBJS" AC_SUBST(LIBOBJ_WITHOUT_CTIMEARC4) @@ -1430,7 +1431,6 @@ if test "$USE_NSS" = "no"; then AC_REPLACE_FUNCS(arc4random) AC_REPLACE_FUNCS(arc4random_uniform) if test "$ac_cv_func_arc4random" = "no"; then - AC_LIBOBJ(explicit_bzero) AC_LIBOBJ(arc4_lock) AC_CHECK_FUNCS([getentropy],,[ if test "$USE_WINSOCK" = 1; then @@ -1755,6 +1755,11 @@ char *strsep(char **stringp, const char *delim); int isblank(int c); #endif +#ifndef HAVE_EXPLICIT_BZERO +#define explicit_bzero unbound_explicit_bzero +void explicit_bzero(void* buf, size_t len); +#endif + #if defined(HAVE_INET_NTOP) && !HAVE_DECL_INET_NTOP const char *inet_ntop(int af, const void *src, char *dst, size_t size); #endif @@ -1787,7 +1792,6 @@ void *reallocarray(void *ptr, size_t nmemb, size_t size); # endif #endif /* HAVE_LIBRESSL */ #ifndef HAVE_ARC4RANDOM -void explicit_bzero(void* buf, size_t len); int getentropy(void* buf, size_t len); uint32_t arc4random(void); void arc4random_buf(void* buf, size_t n); diff --git a/doc/Changelog b/doc/Changelog index 45fe8eadc..520aa6cf7 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +17 September 2018: Wouter + - Fix compile on Mac for unbound, provide explicit_bzero when libc + does not have it. + 13 September 2018: Wouter - Fix seed for random backup code to use explicit zero when wiped. - exit log routine is annotated as noreturn function. -- 2.47.3