diff options
author | Matt Johnston <matt@ucc.asn.au> | 2006-06-06 15:40:09 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2006-06-06 15:40:09 +0000 |
commit | 1e26b86f1508b0a7586b2e9dfd2ac328b94e8c42 (patch) | |
tree | a02a6c561eb6de6d0744e2cc5f1f76463eb0d83e /random.c | |
parent | f7caf6f5c640cb1756c01184898f176438a3a0c2 (diff) | |
parent | b6b96f884110f96a31e35139196749ed7f91462c (diff) |
propagate from branch 'au.asn.ucc.matt.dropbear' (head 138a11bc1e2babcd8b1182e6cb2a85d4e9404b11)
to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head 12b2f59db65e7339d340e95ac67d6d9ddb193c2b)
--HG--
branch : agent-client
extra : convert_revision : d82c25da2f7e4fb6da510d806c64344e80bb270d
Diffstat (limited to 'random.c')
-rw-r--r-- | random.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -31,7 +31,8 @@ static int donerandinit = 0; /* 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 @@ void seedrandom() { 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 @@ void seedrandom() { * 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)); |