Fix potential security problems in random number generator

[originally from svn r190]
This commit is contained in:
Simon Tatham 1999-08-02 08:35:11 +00:00
Родитель 4e889024e3
Коммит 5aab53ce52
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -52,8 +52,8 @@ void random_add_noise(void *noise, int length) {
pool.incomingpos = 0; pool.incomingpos = 0;
} }
memcpy(pool.incomingb, p, length); memcpy(pool.incomingb + pool_incomingpos, p, length);
pool.incomingpos = length; pool.incomingpos += length;
} }
void random_stir(void) { void random_stir(void) {
@ -121,7 +121,7 @@ void random_stir(void) {
* there'll be some extra bizarreness there. * there'll be some extra bizarreness there.
*/ */
SHATransform(digest, block); SHATransform(digest, block);
memcpy(digest, pool.incoming, sizeof(digest)); memcpy(pool.incoming, digest, sizeof(digest));
pool.poolpos = sizeof(pool.incoming); pool.poolpos = sizeof(pool.incoming);
} }
@ -137,8 +137,8 @@ static void random_add_heavynoise(void *noise, int length) {
pool.poolpos = 0; pool.poolpos = 0;
} }
memcpy(pool.pool, p, length); memcpy(pool.pool + pool.poolpos, p, length);
pool.poolpos = length; pool.poolpos += length;
} }
void random_init(void) { void random_init(void) {