diff options
author | OBATA Akio <obache@wizdas.com> | 2019-08-18 18:28:04 +0900 |
---|---|---|
committer | TDE Gitea <gitea@mirror.git.trinitydesktop.org> | 2019-08-18 13:38:50 +0000 |
commit | 027c45db6f63a04eb31eac481f9264ab9760dce1 (patch) | |
tree | ae692633870b22d4cfda6838c92c8b1ebcc64c8a | |
parent | 60e5e374553ce75f2e499888c8592bbeaa6f8b1e (diff) | |
download | tdebase-027c45db6f63a04eb31eac481f9264ab9760dce1.tar.gz tdebase-027c45db6f63a04eb31eac481f9264ab9760dce1.zip |
Change to use arc4random_buf(3) if available
Signed-off-by: OBATA Akio <obache@wizdas.com>
-rw-r--r-- | config.h.cmake | 1 | ||||
-rw-r--r-- | tdm/ConfigureChecks.cmake | 1 | ||||
-rw-r--r-- | tdm/backend/genauth.c | 5 |
3 files changed, 6 insertions, 1 deletions
diff --git a/config.h.cmake b/config.h.cmake index d2c2a8bfb..c7c98fbc4 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -188,6 +188,7 @@ #cmakedefine HAVE_ARC4RANDOM 1 #cmakedefine DEV_RANDOM "@DEV_RANDOM@" +#cmakedefine HAVE_ARC4RANDOM_BUF 1 #cmakedefine USE_PAM 1 #cmakedefine TDM_PAM_SERVICE "@TDM_PAM_SERVICE@" diff --git a/tdm/ConfigureChecks.cmake b/tdm/ConfigureChecks.cmake index cb333aa61..cb5615243 100644 --- a/tdm/ConfigureChecks.cmake +++ b/tdm/ConfigureChecks.cmake @@ -98,6 +98,7 @@ if( NOT HAVE_ARC4RANDOM ) set( DEV_RANDOM "/dev/random" CACHE INTERNAL "" FORCE ) endif( ) endif (NOT HAVE_ARC4RANDOM) +check_function_exists( arc4random_buf HAVE_ARC4RANDOM_BUF ) # Xau pkg_search_module( XAU xau ) diff --git a/tdm/backend/genauth.c b/tdm/backend/genauth.c index 6da95cce0..1bde2fc85 100644 --- a/tdm/backend/genauth.c +++ b/tdm/backend/genauth.c @@ -432,7 +432,10 @@ AddPreGetEntropy( void ) int GenerateAuthData( char *auth, int len ) { -#ifdef HAVE_ARC4RANDOM +#ifdef HAVE_ARC4RANDOM_BUF + arc4random_buf((void*)auth, (size_t)len); + return 1; +#elif defined(HAVE_ARC4RANDOM) int i; unsigned *rnd = (unsigned *)auth; if (sizeof(unsigned) == 4) |