]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_10] check for arc4random_addrandom()
authorEvan Hunt <each@isc.org>
Wed, 7 May 2014 15:58:47 +0000 (08:58 -0700)
committerEvan Hunt <each@isc.org>
Wed, 7 May 2014 15:58:47 +0000 (08:58 -0700)
3840. [port] Check for arc4random_addrandom() before using it;
it's been removed from OpenBSD 5.5. [RT #35907]

(cherry picked from commit 1ea6e09c376b1351c614474a88675b1a9bda6571)

CHANGES
acconfig.h
config.h.in
configure
configure.in
lib/isc/random.c

diff --git a/CHANGES b/CHANGES
index cd04d58202993a47f9c61e35b07017a6cbafcf11..7a40a2815229e94880742fe1e9bbe01ce590210b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3840.  [port]          Check for arc4random_addrandom() before using it;
+                       it's been removed from OpenBSD 5.5. [RT #35907]
+
 3839.  [test]          Use only posix-compatible shell in system tests.
                        [RT #35625]
 
index 34feb556a0a8ff5f10befdd2c34a7cd99c8fd39e..125d18e4661d8a92bf568006e31e775d21f444bd 100644 (file)
@@ -73,6 +73,9 @@
 /** define if arc4random() exists */
 #undef HAVE_ARC4RANDOM
 
+/** define if arc4random_addrandom() exists */
+#undef HAVE_ARC4RANDOM_ADDRANDOM
+
 /**
  * define if pthread_setconcurrency() should be called to tell the
  * OS how many threads we might want to run.
index 0f6658fdf3226aeee48a34a00ef53b409e905364..09d77b42653ebf0ca0ef61ab6250cd5cb0d23d73 100644 (file)
@@ -73,6 +73,9 @@
 /** define if arc4random() exists */
 #undef HAVE_ARC4RANDOM
 
+/** define if arc4random_addrandom() exists */
+#undef HAVE_ARC4RANDOM_ADDRANDOM
+
 /**
  * define if pthread_setconcurrency() should be called to tell the
  * OS how many threads we might want to run.
index ee3c490a0377535dfcb86f068957ee89848f2378..21a014c2b3a7c02f2d12011711c4ca2961226fc1 100755 (executable)
--- a/configure
+++ b/configure
@@ -14113,7 +14113,8 @@ fi
 
 
 #
-# Do we have arc4random() ?
+# Do we have arc4random(), etc ? arc4random_addrandom() has been removed
+# from OpenBSD 5.5 onwards.
 #
 ac_fn_c_check_func "$LINENO" "arc4random" "ac_cv_func_arc4random"
 if test "x$ac_cv_func_arc4random" = xyes; then :
@@ -14121,6 +14122,12 @@ if test "x$ac_cv_func_arc4random" = xyes; then :
 
 fi
 
+ac_fn_c_check_func "$LINENO" "arc4random_addrandom" "ac_cv_func_arc4random_addrandom"
+if test "x$ac_cv_func_arc4random_addrandom" = xyes; then :
+  $as_echo "#define HAVE_ARC4RANDOM_ADDRANDOM 1" >>confdefs.h
+
+fi
+
 
 #
 # Begin pthreads checking.
index 43de6e6ebc94c19dc7b8e1f4467db95d795c80b7..6bca7fe1ce2a8abe0358fdf41ee44a367c0bb761 100644 (file)
@@ -967,9 +967,11 @@ fi
 AC_SUBST(CHECK_DSA)
 
 #
-# Do we have arc4random() ?
+# Do we have arc4random(), etc ? arc4random_addrandom() has been removed
+# from OpenBSD 5.5 onwards.
 #
 AC_CHECK_FUNC(arc4random, AC_DEFINE(HAVE_ARC4RANDOM))
+AC_CHECK_FUNC(arc4random_addrandom, AC_DEFINE(HAVE_ARC4RANDOM_ADDRANDOM))
 
 sinclude(config.threads.in)dnl
 
index 4c48e60fd77d4c966655cb48f1611e44ce366fdf..624ac1bad9c4e3498d060a47a23097610dc3b773 100644 (file)
@@ -67,8 +67,16 @@ isc_random_seed(isc_uint32_t seed)
 
 #ifndef HAVE_ARC4RANDOM
        srand(seed);
-#else
+#elif defined(HAVE_ARC4RANDOM_ADDRANDOM)
        arc4random_addrandom((u_char *) &seed, sizeof(isc_uint32_t));
+#else
+       /*
+        * If arcrandom() is available and no corresponding seeding
+        * function arc4random_addrandom() is available, no seeding is
+        * done on such platforms (e.g., OpenBSD 5.5). This is because
+        * the OS itself is supposed to seed the RNG and it is assumed
+        * that no explicit seeding is required.
+        */
 #endif
 }