summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2013-07-03 23:27:04 +0000
committerache <ache@FreeBSD.org>2013-07-03 23:27:04 +0000
commitbb909148e91fe6038deabe6aec889b349d126851 (patch)
treefdd0c9e177d7bd5e15c9612d1cb489593d54b6ae
parentbfcf8b6dd678beced16df63a3c17f7740eebbe86 (diff)
downloadFreeBSD-src-bb909148e91fe6038deabe6aec889b349d126851.zip
FreeBSD-src-bb909148e91fe6038deabe6aec889b349d126851.tar.gz
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
-rw-r--r--lib/libc/stdlib/rand.c6
1 files changed, 5 insertions, 1 deletions
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);
}
OpenPOWER on IntegriCloud