From 9f675b8a850031138c8408a54fd14769461c4e4b Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Wed, 15 Jul 2020 23:53:19 +0200 Subject: [PATCH] Use explicit_bzero() where available, not just on OpenBSD (#282) --- configure.ac | 1 + i3lock.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 474f750..397bda4 100644 --- a/configure.ac +++ b/configure.ac @@ -66,6 +66,7 @@ AC_FUNC_FORK AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_FUNC_STRNLEN AC_CHECK_FUNCS([atexit dup2 ftruncate getcwd gettimeofday localtime_r memchr memset mkdir rmdir setlocale socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strspn strstr strtol strtoul], , [AC_MSG_FAILURE([cannot find the $ac_func function, which i3lock requires])]) +AC_CHECK_FUNCS([explicit_bzero]) # Checks for libraries. diff --git a/i3lock.c b/i3lock.c index bab41e0..0c3f5b6 100644 --- a/i3lock.c +++ b/i3lock.c @@ -27,7 +27,6 @@ #include #endif #include -#include #include #include #include @@ -35,7 +34,7 @@ #include #include #include -#ifdef __OpenBSD__ +#ifdef HAVE_EXPLICIT_BZERO #include /* explicit_bzero(3) */ #endif #include @@ -175,7 +174,7 @@ static bool load_compose_table(const char *locale) { * */ static void clear_password_memory(void) { -#ifdef __OpenBSD__ +#ifdef HAVE_EXPLICIT_BZERO /* Use explicit_bzero(3) which was explicitly designed not to be * optimized out by the compiler. */ explicit_bzero(password, strlen(password));