Use explicit_bzero() where available, not just on OpenBSD (#282)

pull/289/head
Michael Ortmann 2020-07-15 23:53:19 +02:00 committed by GitHub
parent 79d102a70d
commit 9f675b8a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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.

View File

@ -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));