summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-04-18 06:42:22 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-04-18 06:42:22 +0000
commitadd7cd1933b616a68b7facc7786f42ec7a011711 (patch)
tree33825c4d3f64a10ef8ddd0dcbfcdec520535f008 /sys/netinet
parentd9c80fcabe39b1183981cf36eb50ed872990f399 (diff)
use arc4random_uniform() for random number requests that are not a
power of two. use arc4random_bytes() when requesting more than a word of PRNG output. ok deraadt@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/igmp_var.h4
-rw-r--r--sys/netinet/in_pcb.c6
-rw-r--r--sys/netinet/ip_ipsp.c4
3 files changed, 7 insertions, 7 deletions
diff --git a/sys/netinet/igmp_var.h b/sys/netinet/igmp_var.h
index c0aaa286ce9..ea066093ec4 100644
--- a/sys/netinet/igmp_var.h
+++ b/sys/netinet/igmp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp_var.h,v 1.8 2007/12/14 18:33:40 deraadt Exp $ */
+/* $OpenBSD: igmp_var.h,v 1.9 2008/04/18 06:42:20 djm Exp $ */
/* $NetBSD: igmp_var.h,v 1.9 1996/02/13 23:41:31 christos Exp $ */
/*
@@ -85,7 +85,7 @@ extern struct igmpstat igmpstat;
* DELAY * countdown frequency). We assume that the routine random()
* is defined somewhere (and that it returns a positive number).
*/
-#define IGMP_RANDOM_DELAY(X) (arc4random() % (X) + 1)
+#define IGMP_RANDOM_DELAY(X) (arc4random_uniform(X) + 1)
void igmp_init(void);
void igmp_input(struct mbuf *, ...);
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index e496b8c5931..88acbfa09ed 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.92 2007/12/30 21:13:27 claudio Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.93 2008/04/18 06:42:20 djm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -335,7 +335,7 @@ in_pcbbind(v, nam)
*/
count = first - last;
if (count)
- *lastport = first - (arc4random() % count);
+ *lastport = first - arc4random_uniform(count);
do {
if (count-- < 0) /* completely used? */
@@ -353,7 +353,7 @@ in_pcbbind(v, nam)
*/
count = last - first;
if (count)
- *lastport = first + (arc4random() % count);
+ *lastport = first + arc4random_uniform(count);
do {
if (count-- < 0) /* completely used? */
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index 993fc376bf1..307aa0ab529 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.170 2007/10/29 16:19:23 chl Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.171 2008/04/18 06:42:20 djm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -232,7 +232,7 @@ reserve_spi(u_int32_t sspi, u_int32_t tspi, union sockaddr_union *src,
if (sspi == tspi) /* Specific SPI asked. */
spi = tspi;
else /* Range specified */
- spi = sspi + (arc4random() % (tspi - sspi));
+ spi = sspi + arc4random_uniform(tspi - sspi);
/* Don't allocate reserved SPIs. */
if (spi >= SPI_RESERVED_MIN && spi <= SPI_RESERVED_MAX)