summaryrefslogtreecommitdiff
path: root/sys/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2014-01-19 12:45:37 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2014-01-19 12:45:37 +0000
commit28cc8c738305152ba1636b91a1fc01ed7bcc4d40 (patch)
tree667da0156500e5484c9dc2c21d8068352afa40fd /sys/lib
parenta69dcedd6829f0cd8f3dd427ebba96d41ed91e35 (diff)
Initialize ci_randseed better using arc4random() + a trick. Remove the
libkern srandom() API since it is not suitable for this use. ok kettenis miod
Diffstat (limited to 'sys/lib')
-rw-r--r--sys/lib/libkern/libkern.h3
-rw-r--r--sys/lib/libkern/random.c18
2 files changed, 4 insertions, 17 deletions
diff --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h
index 9de6fbf84b4..43f38bab50c 100644
--- a/sys/lib/libkern/libkern.h
+++ b/sys/lib/libkern/libkern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libkern.h,v 1.31 2013/07/11 01:20:32 jsg Exp $ */
+/* $OpenBSD: libkern.h,v 1.32 2014/01/19 12:45:36 deraadt Exp $ */
/* $NetBSD: libkern.h,v 1.7 1996/03/14 18:52:08 christos Exp $ */
/*-
@@ -153,7 +153,6 @@ int flsl(long);
void *memchr(const void *, int, size_t);
int memcmp(const void *, const void *, size_t);
u_int32_t random(void);
-void srandom(u_int32_t);
int scanc(u_int, const u_char *, const u_char [], int);
int skpc(int, size_t, u_char *);
size_t strlen(const char *);
diff --git a/sys/lib/libkern/random.c b/sys/lib/libkern/random.c
index d78e1b0607a..26a9173702d 100644
--- a/sys/lib/libkern/random.c
+++ b/sys/lib/libkern/random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: random.c,v 1.8 2008/10/15 23:23:51 deraadt Exp $ */
+/* $OpenBSD: random.c,v 1.9 2014/01/19 12:45:36 deraadt Exp $ */
/* $NetBSD: random.c,v 1.2 1994/10/26 06:42:42 cgd Exp $ */
/*-
@@ -38,22 +38,10 @@
#include <lib/libkern/libkern.h>
/*
- * Pseudo-random number generator for randomizing the profiling clock,
- * and whatever else we might use it for. The result is uniform on
- * [0, 2^31 - 1].
+ * Pseudo-random number generator for randomizing the profiling clock.
+ * The result is uniform on [0, 2^31 - 1].
*/
-void
-srandom(u_int32_t seed)
-{
- struct cpu_info *ci = curcpu();
-
- seed &= 0x7fffffff;
- if (seed == 0)
- seed = 1;
- ci->ci_randseed = seed;
-}
-
u_int32_t
random(void)
{