commit 9f675b8a850031138c8408a54fd14769461c4e4b
parent 79d102a70d9adcce98640282c36b0557d6dec72f
Author: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com>
Date: Wed, 15 Jul 2020 23:53:19 +0200
Use explicit_bzero() where available, not just on OpenBSD (#282)
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git 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
@@ -27,7 +27,6 @@
#include <security/pam_appl.h>
#endif
#include <getopt.h>
-#include <string.h>
#include <ev.h>
#include <sys/mman.h>
#include <xkbcommon/xkbcommon.h>
@@ -35,7 +34,7 @@
#include <xkbcommon/xkbcommon-x11.h>
#include <cairo.h>
#include <cairo/cairo-xcb.h>
-#ifdef __OpenBSD__
+#ifdef HAVE_EXPLICIT_BZERO
#include <strings.h> /* explicit_bzero(3) */
#endif
#include <xcb/xcb_aux.h>
@@ -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));