From bb909148e91fe6038deabe6aec889b349d126851 Mon Sep 17 00:00:00 2001 From: ache Date: Wed, 3 Jul 2013 23:27:04 +0000 Subject: In addition to prev. commit, for repeated rand_r(3) calls don't forget to compensate back at the end incremented at the start internal state. MFC after: 2 weeks --- lib/libc/stdlib/rand.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 676c95e..58b3753 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -90,7 +90,11 @@ rand_r(unsigned int *ctx) #endif int r = do_rand(&val); - *ctx = (unsigned int) val; +#ifdef USE_WEAK_SEEDING + *ctx = (unsigned int)val; +#else + *ctx = (unsigned int)(val - 1); +#endif return (r); } -- cgit v1.1