From e7dfcc6ddd2cf1ea170e7a3d6199fae22924698c Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 5 Feb 1997 15:48:21 +0000 Subject: [PATCH] use arc4random() --- sys/netinet/igmp.c | 3 ++- sys/netinet/igmp_var.h | 4 ++-- sys/netinet/in_pcb.c | 7 ++++--- sys/netinet/tcp_input.c | 5 +++-- sys/netinet/tcp_subr.c | 5 +++-- sys/netinet/tcp_timer.c | 5 +++-- sys/netinet/tcp_usrreq.c | 5 +++-- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index e37d502e7e5..b9099aaac54 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: igmp.c,v 1.2 1996/03/03 22:30:26 niklas Exp $ */ +/* $OpenBSD: igmp.c,v 1.3 1997/02/05 15:48:21 deraadt Exp $ */ /* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */ /* @@ -27,6 +27,7 @@ #include #include #include +#include #include diff --git a/sys/netinet/igmp_var.h b/sys/netinet/igmp_var.h index dccbd637b81..f31ef56f019 100644 --- a/sys/netinet/igmp_var.h +++ b/sys/netinet/igmp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: igmp_var.h,v 1.2 1996/03/03 22:30:27 niklas Exp $ */ +/* $OpenBSD: igmp_var.h,v 1.3 1997/02/05 15:48:22 deraadt Exp $ */ /* $NetBSD: igmp_var.h,v 1.9 1996/02/13 23:41:31 christos Exp $ */ /* @@ -71,7 +71,7 @@ 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) (random() % (X) + 1) +#define IGMP_RANDOM_DELAY(X) (arc4random() % (X) + 1) void igmp_init __P((void)); void igmp_input __P((struct mbuf *, ...)); diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 3a74cd535f2..ff1f639563c 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.13 1997/01/15 03:27:14 kstailey Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.14 1997/02/05 15:48:23 deraadt Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -57,6 +57,7 @@ #include #include #include +#include struct in_addr zeroin_addr; @@ -217,7 +218,7 @@ portloop: */ if (loopcount == 0) { /* only do this once. */ old = first; - first -= (random() % (first - last)); + first -= (arc4random() % (first - last)); } count = first - last; @@ -243,7 +244,7 @@ portloop: */ if (loopcount == 0) { /* only do this once. */ old = first; - first += (random() % (last - first)); + first += (arc4random() % (last - first)); } count = last - first; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index e0d20e0c6f1..ea37f2be8d5 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.8 1996/09/25 11:39:56 niklas Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.9 1997/02/05 15:48:24 deraadt Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -61,6 +61,7 @@ #include #include #include +#include #include @@ -676,7 +677,7 @@ findpcb: #ifdef TCP_COMPAT_42 tcp_iss += TCP_ISSINCR/2; #else /* TCP_COMPAT_42 */ - tcp_iss += random() % (TCP_ISSINCR / 2) + 1; + tcp_iss += arc4random() % (TCP_ISSINCR / 2) + 1; #endif /* !TCP_COMPAT_42 */ tp->irs = ti->ti_seq; tcp_sendseqinit(tp); diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 09d139a31b0..c53bc198c12 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_subr.c,v 1.7 1996/07/29 22:01:50 niklas Exp $ */ +/* $OpenBSD: tcp_subr.c,v 1.8 1997/02/05 15:48:25 deraadt Exp $ */ /* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */ /* @@ -61,6 +61,7 @@ #include #include #include +#include /* patchable/settable parameters for tcp */ int tcp_mssdflt = TCP_MSS; @@ -94,7 +95,7 @@ tcp_init() #ifdef TCP_COMPAT_42 tcp_iss = 1; /* wrong */ #else /* TCP_COMPAT_42 */ - tcp_iss = random() + 1; + tcp_iss = arc4random() + 1; #endif /* !TCP_COMPAT_42 */ in_pcbinit(&tcbtable, tcbhashsize); if (max_protohdr < sizeof(struct tcpiphdr)) diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 14e8d42ca7b..ba972adff32 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.c,v 1.6 1996/09/12 06:19:57 tholo Exp $ */ +/* $OpenBSD: tcp_timer.c,v 1.7 1997/02/05 15:48:26 deraadt Exp $ */ /* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */ /* @@ -60,6 +60,7 @@ #include #include #include +#include int tcp_keepidle = TCPTV_KEEP_IDLE; int tcp_keepintvl = TCPTV_KEEPINTVL; @@ -143,7 +144,7 @@ tpgone: if ((int)tcp_iss < 0) tcp_iss = 0; /* XXX */ #else /* TCP_COMPAT_42 */ - tcp_iss += random() % (TCP_ISSINCR / PR_SLOWHZ) + 1; /* increment iss */ + tcp_iss += arc4random() % (TCP_ISSINCR / PR_SLOWHZ) + 1; /* increment iss */ #endif /* !TCP_COMPAT_42 */ tcp_now++; /* for timestamps */ splx(s); diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 233403a8680..19647d2695f 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.7 1996/09/20 22:53:12 deraadt Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.8 1997/02/05 15:48:27 deraadt Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -67,6 +67,7 @@ #include #include #include +#include /* * TCP protocol interface to socket abstraction. @@ -215,7 +216,7 @@ tcp_usrreq(so, req, m, nam, control) #ifdef TCP_COMPAT_42 tcp_iss += TCP_ISSINCR/2; #else /* TCP_COMPAT_42 */ - tcp_iss += random() % (TCP_ISSINCR / 2) + 1; + tcp_iss += arc4random() % (TCP_ISSINCR / 2) + 1; #endif /* !TCP_COMPAT_42 */ tcp_sendseqinit(tp); error = tcp_output(tp); -- 2.20.1