summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2014-02-10 01:38:07 +0000
committerguenther <guenther@openbsd.org>2014-02-10 01:38:07 +0000
commitffd93db080503b2c7abc6ed3a654837abd50c58b (patch)
treed6dbae4114f283b803438fdaef86ff6c5ea212ca /sys/kern/kern_fork.c
parentdrm/radeon: fix render backend setup for SI and CIK (diff)
downloadwireguard-openbsd-ffd93db080503b2c7abc6ed3a654837abd50c58b.tar.xz
wireguard-openbsd-ffd93db080503b2c7abc6ed3a654837abd50c58b.zip
arc4random_uniform() returns a value strictly less than its argument; fix
arithmetic so that PID_MAX can be reached. ok otto@ zhuk@ miod@
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 9188a7d50a3..5e4b944e8f2 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.156 2014/01/20 21:19:28 guenther Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.157 2014/02/10 01:38:07 guenther Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -570,7 +570,7 @@ allocpid(void)
pid = ++lastpid;
} else {
do {
- pid = 1 + arc4random_uniform(PID_MAX - 1);
+ pid = 1 + arc4random_uniform(PID_MAX);
} while (ispidtaken(pid));
}