summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2001-11-03 02:14:10 +0000
committerobrien <obrien@FreeBSD.org>2001-11-03 02:14:10 +0000
commitf1008910161a7140aea35cd535216b766df0bbc0 (patch)
treed5f842cc18b9b203149a0b2e89ad3587f480c64f /contrib
parent9bd91d26bea7f37f53f546cb36b97212367b2b6d (diff)
downloadFreeBSD-src-f1008910161a7140aea35cd535216b766df0bbc0.zip
FreeBSD-src-f1008910161a7140aea35cd535216b766df0bbc0.tar.gz
Tighten up the random seeding a little bit more. getpid() alone only
affect only lower bits of seed which would resulte in the same seed for sequences of fast-started awk's resulting the same random sequence. Submitted by: ache
Diffstat (limited to 'contrib')
-rw-r--r--contrib/awk/builtin.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/awk/builtin.c b/contrib/awk/builtin.c
index 240dca4..dcf3ac3 100644
--- a/contrib/awk/builtin.c
+++ b/contrib/awk/builtin.c
@@ -1509,7 +1509,8 @@ do_srand(NODE *tree)
if (tree == NULL)
#ifdef __FreeBSD__
- srandom((unsigned int) (save_seed = (long) time((time_t *) 0) ^ getpid()));
+ srandom((unsigned int) (save_seed = (long) time((time_t *) 0)
+ ^ (getpid() << 16)));
#else
srandom((unsigned int) (save_seed = (long) time((time_t *) 0)));
#endif
OpenPOWER on IntegriCloud