mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Owen's just pointed out that random_stir() is capable of recursion.
I'm sure I didn't mean that to happen! Added a lock to stop it. [originally from svn r5166]
This commit is contained in:
parent
9f8182ffd7
commit
31133eb077
12
sshrand.c
12
sshrand.c
@ -40,6 +40,8 @@ struct RandPool {
|
|||||||
|
|
||||||
unsigned char incomingb[HASHINPUT];
|
unsigned char incomingb[HASHINPUT];
|
||||||
int incomingpos;
|
int incomingpos;
|
||||||
|
|
||||||
|
int stir_pending;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct RandPool pool;
|
static struct RandPool pool;
|
||||||
@ -52,6 +54,14 @@ static void random_stir(void)
|
|||||||
word32 digest[HASHSIZE / sizeof(word32)];
|
word32 digest[HASHSIZE / sizeof(word32)];
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* noise_get_light will call random_add_noise, which may call
|
||||||
|
* back to here. Prevent recursive stirs.
|
||||||
|
*/
|
||||||
|
if (pool.stir_pending)
|
||||||
|
return;
|
||||||
|
pool.stir_pending = TRUE;
|
||||||
|
|
||||||
noise_get_light(random_add_noise);
|
noise_get_light(random_add_noise);
|
||||||
|
|
||||||
SHATransform((word32 *) pool.incoming, (word32 *) pool.incomingb);
|
SHATransform((word32 *) pool.incoming, (word32 *) pool.incomingb);
|
||||||
@ -115,6 +125,8 @@ static void random_stir(void)
|
|||||||
memcpy(pool.incoming, digest, sizeof(digest));
|
memcpy(pool.incoming, digest, sizeof(digest));
|
||||||
|
|
||||||
pool.poolpos = sizeof(pool.incoming);
|
pool.poolpos = sizeof(pool.incoming);
|
||||||
|
|
||||||
|
pool.stir_pending = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void random_add_noise(void *noise, int length)
|
void random_add_noise(void *noise, int length)
|
||||||
|
Loading…
Reference in New Issue
Block a user