Page MenuHomeFreeBSD

D29385.id.diff
No OneTemporary

D29385.id.diff

diff --git a/share/man/man9/random.9 b/share/man/man9/random.9
--- a/share/man/man9/random.9
+++ b/share/man/man9/random.9
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\" "
-.Dd December 26, 2019
+.Dd March 22, 2021
.Dt RANDOM 9
.Os
.Sh NAME
@@ -132,17 +132,13 @@
returned.
.Pp
The deprecated
-.Xr random 9
-function will produce a sequence of pseudorandom numbers using a similar weak
-linear congruential generator as
-.Xr rand 3
-(the 1988 Park-Miller LCG).
+.Fn random
+function will return a 31-bit value.
It is obsolete and scheduled to be removed in
-.Fx 13.0 .
-It is strongly advised that the
-.Xr random 9
-function not be used to generate random numbers.
-See
+.Fx 14.0 .
+Consider
+.Xr prng 9
+instead and see
.Sx SECURITY CONSIDERATIONS .
.Sh RETURN VALUES
The
@@ -167,6 +163,13 @@
.Fn read_random_uio
returns zero when successful,
otherwise an error code is returned.
+.Pp
+.Fn random
+returns numbers
+in the range from 0 to
+.if t 2\u\s731\s10\d\(mi1.
+.if n (2**31)\(mi1.
+
.Sh ERRORS
.Fn read_random_uio
may fail if:
diff --git a/sys/libkern/random.c b/sys/libkern/random.c
--- a/sys/libkern/random.c
+++ b/sys/libkern/random.c
@@ -45,5 +45,5 @@
u_long
random(void)
{
- return (prng32());
+ return (prng32() & 0x7fffffff);
}

File Metadata

Mime Type
text/plain
Expires
Tue, Sep 24, 9:59 AM (4 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
12654173
Default Alt Text
D29385.id.diff (1 KB)

Event Timeline