Module: ngircd.git Branch: master Commit: 8e6db769ac549cfe26042f7d51ae8a301d8fc569 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=8e6db...
Author: Federico G. Schwindt fgsch@lodoss.net Date: Wed Oct 23 16:00:26 2013 +0100
Check and call arc4random_stir() if present
FreeBSD prior to 10.0 does not automatically stir on fork(). Same with current NetBSD. If arc4random_stir() is present assume is needed and call it instead of srand().
---
configure.ng | 6 +++--- src/ngircd/proc.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/configure.ng b/configure.ng index 16f970f..e3f51cf 100644 --- a/configure.ng +++ b/configure.ng @@ -187,9 +187,9 @@ AC_CHECK_FUNCS([ \
# Optional functions AC_CHECK_FUNCS_ONCE([ \ - arc4random gai_strerror getaddrinfo getnameinfo inet_aton sigaction \ - sigprocmask snprintf vsnprintf strdup strndup strlcpy strlcat strtok_r \ - waitpid]) + arc4random arc4random_stir gai_strerror getaddrinfo getnameinfo inet_aton + sigaction sigprocmask snprintf vsnprintf strdup strndup strlcpy strlcat \ + strtok_r waitpid])
# -- Configuration options --
diff --git a/src/ngircd/proc.c b/src/ngircd/proc.c index d290f3b..a5afb50 100644 --- a/src/ngircd/proc.c +++ b/src/ngircd/proc.c @@ -77,6 +77,9 @@ Proc_Fork(PROC_STAT *proc, int *pipefds, void (*cbfunc)(int, short), int timeout return -1; case 0: /* New child process: */ +#ifdef HAVE_ARC4RANDOM_STIR + arc4random_stir(); +#endif #ifndef HAVE_ARC4RANDOM srand(seed ^ (unsigned int)time(NULL) ^ getpid()); #endif