summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2003-02-14 17:12:54 +0000
committerderaadt <deraadt@openbsd.org>2003-02-14 17:12:54 +0000
commit63f3e716ea51528f2d7dc503c6c118be56409027 (patch)
treeadcfa2f4c4d385b56cdc71fdf4cfab4e17169287 /lib/libc
parentFix NFS diskless boot when PF is used. (diff)
downloadwireguard-openbsd-63f3e716ea51528f2d7dc503c6c118be56409027.tar.xz
wireguard-openbsd-63f3e716ea51528f2d7dc503c6c118be56409027.zip
re-stir if pid changes; markus & me
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/crypt/arc4random.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/crypt/arc4random.c b/lib/libc/crypt/arc4random.c
index 4e916ab99a1..a41001bcc3d 100644
--- a/lib/libc/crypt/arc4random.c
+++ b/lib/libc/crypt/arc4random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */
+/* $OpenBSD: arc4random.c,v 1.7 2003/02/14 17:12:54 deraadt Exp $ */
/*
* Arc4 random number generator for OpenBSD.
@@ -44,8 +44,9 @@ struct arc4_stream {
u_int8_t s[256];
};
-int rs_initialized;
+static int rs_initialized;
static struct arc4_stream rs;
+static pid_t arc4_stir_pid;
static inline void
arc4_init(as)
@@ -113,6 +114,7 @@ arc4_stir(as)
/* fd < 0 or failed sysctl ? Ah, what the heck. We'll just take
* whatever was on the stack... */
+ arc4_stir_pid = getpid();
arc4_addrandom(as, (void *) &rdat, sizeof(rdat));
}
@@ -166,7 +168,7 @@ arc4random_addrandom(dat, datlen)
u_int32_t
arc4random()
{
- if (!rs_initialized)
+ if (!rs_initialized || arc4_stir_pid != getpid())
arc4random_stir();
return arc4_getword(&rs);
}