From 9b500bf3eb49c29a7a0be3a1e7093e484cf5a1fd Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 2 Feb 2003 14:27:51 +0000 Subject: For some combinations of variable sizes and RAND_MAX value rand_r() may store less amount bits for seed, than available. Fix it. --- lib/libc/stdlib/rand.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdlib/rand.c') 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); } -- cgit v1.1