File nrpe-more_random.patch of Package nagios-nrpe

Index: src/utils.c
===================================================================
--- src/utils.c.orig
+++ src/utils.c
@@ -90,17 +90,13 @@ void randomize_buffer(char *buffer,int b
 	   ends and the rest of the buffer (padded randomly) starts.
 	***************************************************************/
 
-	/* try to get seed value from /dev/urandom, as its a better source of entropy */
-	fp=fopen("/dev/urandom","r");
-	if(fp!=NULL){
-		seed=fgetc(fp);
-		fclose(fp);
-	        }
-
-	/* else fallback to using the current time as the seed */
-	else
-		seed=(int)time(NULL);
-
+	/***************************************************************
+	   The randomness, produced by the original version, is just 
+	   between 0 and 255. The randomness generated by the line below 
+	   produces more randomness and does not reduce the amount of 
+	   entropy that the linux kernel thinks it has.
+    ***************************************************************/
+	seed=(int)time(NULL)*311-getpid()*359+getppid()*383;
 	srand(seed);
 	for(x=0;x<buffer_size;x++)
 		buffer[x]=(int)'0'+(int)(72.0*rand()/(RAND_MAX+1.0));
openSUSE Build Service is sponsored by