Commit 1f8707c4 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Rolf Eike Beer

use explicit_bzero() if it is present

Differential Revision: https://phabricator.kde.org/D13015
parent 68e9acb8
......@@ -7,6 +7,7 @@ set(PROJECT_VERSION_MAJOR 5)
find_package (ECM 1.2.0 REQUIRED NO_MODULE)
set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
include(CheckFunctionExists)
include(KDEInstallDirs)
find_package(PAM REQUIRED)
......@@ -58,6 +59,14 @@ if (PAM_APPL_PATH)
add_definitions(-DHAVE_PAM_APPL)
endif()
set(CMAKE_REQUIRED_INCLUDES "string.h")
check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
set(CMAKE_REQUIRED_INCLUDES)
if (HAVE_EXPLICIT_BZERO)
add_definitions(-DHAVE_EXPLICIT_BZERO)
endif()
add_library (${library_name} SHARED ${pam_kwallet_SRCS})
set_target_properties (${library_name} PROPERTIES PREFIX "")
target_link_libraries (${library_name}
......
......@@ -21,6 +21,7 @@
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <grp.h>
......@@ -177,11 +178,13 @@ static void wipeString(char *str)
return;
}
size_t len;
const size_t len = strlen (str);
#if HAVE_EXPLICIT_BZERO
explicit_bzero(str, len);
#else
volatile char *vp;
/* Defeats some optimizations */
len = strlen (str);
memset (str, 0xAA, len);
memset (str, 0xBB, len);
......@@ -190,6 +193,7 @@ static void wipeString(char *str)
while (*vp) {
*(vp++) = 0xAA;
}
#endif
free (str);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment