summaryrefslogtreecommitdiff
path: root/sys/altq/altq_classq.h
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-04-20 07:05:53 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-04-20 07:05:53 +0000
commitc0fb0775f102deefbb672e0e3504e9767cf74f20 (patch)
tree5460567270a4682d4bdc1d922c36027d6ece3e17 /sys/altq/altq_classq.h
parenteeab8aabdfc1b30eacd8bf4ff6a97fb0155fe744 (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_classq.h')
-rw-r--r--sys/altq/altq_classq.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/altq/altq_classq.h b/sys/altq/altq_classq.h
index 3ee2aad31c7..4fdb9b43c57 100644
--- a/sys/altq/altq_classq.h
+++ b/sys/altq/altq_classq.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: altq_classq.h,v 1.3 2003/01/07 00:29:28 cloder Exp $ */
+/* $OpenBSD: altq_classq.h,v 1.4 2008/04/20 07:05:51 deraadt Exp $ */
/* $KAME: altq_classq.h,v 1.4 2001/02/09 07:20:40 kjc Exp $ */
/*
@@ -155,7 +155,7 @@ _getq_random(class_queue_t *q)
else {
struct mbuf *prev = NULL;
- n = random() % qlen(q) + 1;
+ n = arc4random_uniform(qlen(q)) + 1;
for (i = 0; i < n; i++) {
prev = m;
m = m->m_nextpkt;