shithub: drawterm

Download patch

ref: bc73cbac76e2d3820db734afdb4e0775f844cfa3
parent: 62ab8e7c1ff1304612400cf1580a0369069b4075
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Aug 21 08:03:23 EDT 2016

kern/posix: remove srandom()/random() code for entropy gathering, will always use /dev/[u]random

--- a/kern/posix.c	Sun Aug 21 08:02:01 2016
+++ b/kern/posix.c	Sun Aug 21 08:03:23 2016
@@ -162,37 +162,25 @@
 	pthread_mutex_unlock(&op->mutex);
 }
 
-int randfd;
+static int randfd;
 #undef open
 void
 randominit(void)
 {
-#ifdef USE_RANDOM
-	srandom(getpid()+fastticks(nil)+ticks());
-#else
 	if((randfd = open("/dev/urandom", OREAD)) < 0)
 	if((randfd = open("/dev/random", OREAD)) < 0)
 		panic("open /dev/random: %r");
-#endif
 }
 
 #undef read
 ulong
 randomread(void *v, ulong n)
 {
-#ifdef USE_RANDOM
-	int i;
-
-	for(i=0; i<n; i++)
-		((uchar*)v)[i] = random();
-	return n;
-#else
 	int m;
 
 	if((m = read(randfd, v, n)) != n)
 		panic("short read from /dev/random: %d but %d", n, m);
 	return m;
-#endif
 }
 
 #undef time