From a9004425a032d7a7141a5437cfabfd02431e2a74 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Sat, 24 Feb 2018 20:25:22 +1100 Subject: [PATCH] Check for bzero and supply if needed. Since explicit_bzero uses it via an indirect it needs to be a function not just a macro. --- configure.ac | 3 +++ openbsd-compat/bsd-misc.c | 8 ++++++++ openbsd-compat/bsd-misc.h | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/configure.ac b/configure.ac index e81e3eccd..e23540e63 100644 --- a/configure.ac +++ b/configure.ac @@ -1695,6 +1695,7 @@ AC_CHECK_FUNCS([ \ bcrypt_pbkdf \ bindresvport_sa \ blf_enc \ + bzero \ cap_rights_limit \ clock \ closefrom \ @@ -1800,6 +1801,8 @@ AC_CHECK_FUNCS([ \ warn \ ]) +AC_CHECK_DECLS([bzero]) + dnl Wide character support. AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth]) diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index 9f6dc8af2..3e8f74b72 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c @@ -282,3 +282,11 @@ llabs(long long j) return (j < 0 ? -j : j); } #endif + +#ifndef HAVE_BZERO +void +bzero(void *b, size_t n) +{ + (void)memset(b, 0, n); +} +#endif diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index 2cfd5dae6..bf5fad188 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h @@ -133,4 +133,8 @@ void warn(const char *, ...) __attribute__((format(printf, 1, 2))); long long llabs(long long); #endif +#ifndef HAVE_DECL_BZERO +void bzero(void *, size_t); +#endif + #endif /* _BSD_MISC_H */