X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/19ad0a17e9c05a3443304b8e8290fb60a772142b..70637309a61321d83a4d0576b875b7dcb7085fa5:/sshrand.c diff --git a/sshrand.c b/sshrand.c index e2386669..a7b3dc4e 100644 --- a/sshrand.c +++ b/sshrand.c @@ -184,12 +184,14 @@ static void random_add_heavynoise_bitbybit(void *noise, int length) void random_init(void) { - memset(&pool, 0, sizeof(pool)); /* just to start with */ + if (!random_active) { + memset(&pool, 0, sizeof(pool)); /* just to start with */ - random_active = 1; + random_active = 1; - noise_get_heavy(random_add_heavynoise_bitbybit); - random_stir(); + noise_get_heavy(random_add_heavynoise_bitbybit); + random_stir(); + } } int random_byte(void) @@ -202,7 +204,7 @@ int random_byte(void) void random_get_savedata(void **data, int *len) { - void *buf = smalloc(POOLSIZE / 2); + void *buf = snewn(POOLSIZE / 2, char); random_stir(); memcpy(buf, pool.pool + pool.poolpos, POOLSIZE / 2); *len = POOLSIZE / 2;