summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2003-02-02 14:27:51 +0000
committerache <ache@FreeBSD.org>2003-02-02 14:27:51 +0000
commit9b500bf3eb49c29a7a0be3a1e7093e484cf5a1fd (patch)
treef2319f87f9a9381db2858eec50d84e496e7ac20e /lib/libc
parent499b47780fe2983e1adaf3c3d27fd247030bb901 (diff)
downloadFreeBSD-src-9b500bf3eb49c29a7a0be3a1e7093e484cf5a1fd.zip
FreeBSD-src-9b500bf3eb49c29a7a0be3a1e7093e484cf5a1fd.tar.gz
For some combinations of variable sizes and RAND_MAX value rand_r()
may store less amount bits for seed, than available. Fix it.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdlib/rand.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index 23cc201..5b81da2 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -86,8 +86,10 @@ int
rand_r(unsigned int *ctx)
{
u_long val = (u_long) *ctx;
- *ctx = do_rand(&val);
- return (int) *ctx;
+ int r = do_rand(&val);
+
+ *ctx = (unsigned int) val;
+ return (r);
}
OpenPOWER on IntegriCloud