diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-04-20 07:05:53 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-04-20 07:05:53 +0000 |
commit | c0fb0775f102deefbb672e0e3504e9767cf74f20 (patch) | |
tree | 5460567270a4682d4bdc1d922c36027d6ece3e17 /sys/altq/altq_cdnr.c | |
parent | eeab8aabdfc1b30eacd8bf4ff6a97fb0155fe744 (diff) |
Do not use random(), which is supposed to be a scheduler-only API (we
should rename it one day). Furthermore, do not do random() % value,
but instead solve both problems using arc4random_uniform()
Problem spotted by drahn, fix ok'd by djm
Diffstat (limited to 'sys/altq/altq_cdnr.c')
-rw-r--r-- | sys/altq/altq_cdnr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/altq/altq_cdnr.c b/sys/altq/altq_cdnr.c index 1519958fb96..e4455ae646d 100644 --- a/sys/altq/altq_cdnr.c +++ b/sys/altq/altq_cdnr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_cdnr.c,v 1.8 2007/09/13 20:40:02 chl Exp $ */ +/* $OpenBSD: altq_cdnr.c,v 1.9 2008/04/20 07:05:51 deraadt Exp $ */ /* $KAME: altq_cdnr.c,v 1.8 2000/12/14 08:12:45 thorpej Exp $ */ /* @@ -846,7 +846,7 @@ tswtcm_input(cb, pktinfo) * marker */ if (avg_rate > tsw->cmtd_rate) { - u_int32_t randval = random() % avg_rate; + u_int32_t randval = arc4random_uniform(avg_rate); if (avg_rate > tsw->peak_rate) { if (randval < avg_rate - tsw->peak_rate) { |