]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Check and call arc4random_stir() if present
authorFederico G. Schwindt <fgsch@lodoss.net>
Wed, 23 Oct 2013 15:00:26 +0000 (16:00 +0100)
committerFederico G. Schwindt <fgsch@lodoss.net>
Wed, 23 Oct 2013 15:00:26 +0000 (16:00 +0100)
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
src/ngircd/proc.c

index 16f970f8dc982d21d96e9f1bdf2de8deba1736f8..e3f51cf0268a086a49c4baddd34a723cc75106ea 100644 (file)
@@ -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 --
 
index d290f3bd100faed3cc17d8d24cd6396443a41131..a5afb5011cb1c468732561d5944fa9f685c1c4e4 100644 (file)
@@ -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