diff random.c @ 320:08b69964e408 agent-client

propagate from branch 'au.asn.ucc.matt.dropbear' (head 138a11bc1e2babcd8b1182e6cb2a85d4e9404b11) to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head 12b2f59db65e7339d340e95ac67d6d9ddb193c2b)
author Matt Johnston <matt@ucc.asn.au>
date Tue, 06 Jun 2006 15:40:09 +0000
parents 79bf1023cf11 36d21680a9d3
children c1e9c81d1d27
line wrap: on
line diff
--- a/random.c	Tue Mar 21 16:20:59 2006 +0000
+++ b/random.c	Tue Jun 06 15:40:09 2006 +0000
@@ -31,7 +31,8 @@
 
 /* this is used to generate unique output from the same hashpool */
 static uint32_t counter = 0;
-#define MAX_COUNTER 1<<31 /* the max value for the counter, so it won't loop */
+/* the max value for the counter, so it won't integer overflow */
+#define MAX_COUNTER 1<<30 
 
 static unsigned char hashpool[SHA1_HASH_SIZE];
 
@@ -129,7 +130,7 @@
 	hash_state hs;
 
 	/* initialise so that things won't warn about
-     * hashing an undefined buffer */
+	 * hashing an undefined buffer */
 	if (!donerandinit) {
 		m_burn(hashpool, sizeof(hashpool));
 	}
@@ -152,18 +153,17 @@
  * the random pools for fork()ed processes. */
 void reseedrandom() {
 
-    pid_t pid;
-    struct timeval tv;
+	pid_t pid;
+	hash_state hs;
+	struct timeval tv;
 
 	if (!donerandinit) {
 		dropbear_exit("seedrandom not done");
 	}
 
-    pid = getpid();
-    gettimeofday(&tv, NULL);
+	pid = getpid();
+	gettimeofday(&tv, NULL);
 
-	hash_state hs;
-	unsigned char hash[SHA1_HASH_SIZE];
 	sha1_init(&hs);
 	sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
 	sha1_process(&hs, (void*)&pid, sizeof(pid));