+1405. [func] Use arc4random() if available.
+
1404. [bug] libbind: ns_name_ntol() could overwite a zero length
buffer.
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: acconfig.h,v 1.38 2002/10/15 04:32:49 marka Exp $ */
+/* $Id: acconfig.h,v 1.39 2002/12/04 01:19:27 marka Exp $ */
/***
*** This file is not to be included by any public header files, because
/* define if gai_strerror() exists */
#undef HAVE_GAISTRERROR
+/* define if arc4random() exists */
+#undef HAVE_ARC4RANDOM
+
/* define if pthread_setconcurrency() should be called to tell the
* OS how many threads we might want to run.
*/
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: genrandom.c,v 1.8 2001/01/09 21:41:04 bwelling Exp $ */
+/* $Id: genrandom.c,v 1.9 2002/12/04 01:19:28 marka Exp $ */
#include <config.h>
exit(1);
}
+#ifndef HAVE_ARC4RANDOM
srand(0x12345678);
+#endif
while (bytes > 0) {
+#ifndef HAVE_ARC4RANDOM
unsigned short int x = (rand() & 0xFFFF);
+#else
+ unsigned short int x = (arc4random() & 0xFFFF);
+#endif
unsigned char c = x & 0xFF;
if (putc(c, fp) == EOF) {
printf("error writing to file\n");
esyscmd([sed "s/^/# /" COPYRIGHT])dnl
AC_DIVERT_POP()dnl
-AC_REVISION($Revision: 1.333 $)
+AC_REVISION($Revision: 1.334 $)
AC_INIT(lib/dns/name.c)
AC_PREREQ(2.13)
;;
esac
+#
+# Do we have arc4random() ?
+#
+AC_CHECK_FUNC(arc4random, AC_DEFINE(HAVE_ARC4RANDOM))
+
#
# Begin pthreads checking.
#
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rdataset.c,v 1.63 2002/04/02 06:06:29 marka Exp $ */
+/* $Id: rdataset.c,v 1.64 2002/12/04 01:19:28 marka Exp $ */
#include <config.h>
*/
for (i = 0; i < count; i++) {
dns_rdata_t rdata;
+#ifndef HAVE_ARC4RANDOM
choice = i + (((u_int)rand()>>3) % (count - i));
+#else
+ choice = i + (((u_int)arc4random()>>3) % (count - i));
+#endif
rdata = shuffled[i];
shuffled[i] = shuffled[choice];
shuffled[choice] = rdata;
/*
* "Cyclic" order.
*/
+#ifndef HAVE_ARC4RANDOM
unsigned int j = (((unsigned int)rand()) >> 3) % count;
+#else
+ unsigned int j = (((unsigned int)arc4random()) >> 3) % count;
+#endif
for (i = 0; i < count; i++) {
if (order != NULL)
sorted[j].key = (*order)(&shuffled[i],
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: random.c,v 1.15 2001/01/09 21:56:22 bwelling Exp $ */
+/* $Id: random.c,v 1.16 2002/12/04 01:19:28 marka Exp $ */
#include <config.h>
static void
initialize_rand(void)
{
+#ifndef HAVE_ARC4RANDOM
srand(time(NULL));
+#endif
}
static void
{
initialize();
+#ifndef HAVE_ARC4RANDOM
srand(seed);
+#else
+ arc4random_addrandom((u_char *) &seed, sizeof(isc_uint32_t));
+#endif
}
void
initialize();
+#ifndef HAVE_ARC4RANDOM
*val = rand();
+#else
+ *val = arc4random();
+#endif
}
isc_uint32_t
if (jitter == 0)
return (max);
else
+#ifndef HAVE_ARC4RANDOM
return (max - rand() % jitter);
+#else
+ return (max - arc4random() % jitter);
+#endif
}