diff options
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | openbsd-compat/Makefile.am | 6 | ||||
-rw-r--r-- | openbsd-compat/explicit_bzero.c | 18 |
3 files changed, 18 insertions, 15 deletions
diff --git a/configure.ac b/configure.ac index f20145bd..a143d5ec 100644 --- a/configure.ac +++ b/configure.ac @@ -547,6 +547,14 @@ AC_SEARCH_LIBS([crypt], ]) AM_CONDITIONAL([SUPPORT_CRYPT], [test $CRYPT_SUPPORT = yes]) +EXPLICIT_BZERO_SUPPORT=no +AC_CHECK_FUNC([explicit_bzero], + [ + AC_DEFINE([HAVE_EXPLICIT_BZERO], [1], + [Define if you have the explicit_bzero() function.]) + EXPLICIT_BZERO_SUPPORT=yes + ]) +AM_CONDITIONAL([SUPPORT_EXPLICIT_BZERO], [test $EXPLICIT_BZERO_SUPPORT = yes]) AC_CHECK_FUNCS([ \ asprintf \ @@ -558,7 +566,6 @@ AC_CHECK_FUNCS([ \ chflags \ dirfd \ endgrent \ - explicit_bzero \ fchflags \ fgetln \ freeaddrinfo \ diff --git a/openbsd-compat/Makefile.am b/openbsd-compat/Makefile.am index 257ce702..97cfcf30 100644 --- a/openbsd-compat/Makefile.am +++ b/openbsd-compat/Makefile.am @@ -3,7 +3,7 @@ noinst_LIBRARIES = libopenbsd-compat.a libopenbsd_compat_a_SOURCES = \ arc4random.c base64.c \ bsd-getpeereid.c bsd-misc.c bsd-waitpid.c \ - entropy.c errc.c event_asr_run.c explicit_bzero.c \ + entropy.c errc.c event_asr_run.c \ fgetln.c getopt.c imsg.c imsg-buffer.c \ libressl.c pidfile.c pw_dup.c reallocarray.c setresguid.c \ setproctitle.c strlcat.c strlcpy.c strmode.c strtonum.c \ @@ -33,6 +33,10 @@ if !SUPPORT_ERRC libopenbsd_compat_a_SOURCES += errc.c endif +if !SUPPORT_EXPLICIT_BZERO +libopenbsd_compat_a_SOURCES += explicit_bzero.c +endif + if !SUPPORT_FMT_SCALED libopenbsd_compat_a_SOURCES += fmt_scaled.c endif diff --git a/openbsd-compat/explicit_bzero.c b/openbsd-compat/explicit_bzero.c index 7abb7bf1..22efe18b 100644 --- a/openbsd-compat/explicit_bzero.c +++ b/openbsd-compat/explicit_bzero.c @@ -1,21 +1,13 @@ -/* OPENBSD ORIGINAL: lib/libc/string/explicit_bzero.c */ -/* $OpenBSD: explicit_bzero.c,v 1.1 2014/01/22 21:06:45 tedu Exp $ */ +/* $OpenBSD: explicit_bzero.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */ /* * Public domain. - * Written by Ted Unangst + * Written by Matthew Dempsky. */ -#include "includes.h" +#include <string.h> -#ifndef HAVE_EXPLICIT_BZERO -#include <strings.h> - -/* - * explicit_bzero - don't let the compiler optimize away bzero - */ void -explicit_bzero(void *p, size_t n) +explicit_bzero(void *buf, size_t len) { - bzero(p, n); + memset(buf, 0, len); } -#endif |