openssl/crypto/rand
Dr. Matthias St. Pierre ece482ff3a RAND_add(): fix heap corruption in error path
This bug was introduced by #7382 which enhanced RAND_add() to
accept large buffer sizes. As a consequence, RAND_add() now fails
for buffer sizes less than 32 bytes (i.e. less than 256 bits).
In addition, rand_drbg_get_entropy() forgets to reset the attached
drbg->pool in the case of an error, which leads to the heap corruption.

The problem occurred with RAND_load_file(), which reads the file in
chunks of 1024 bytes each. If the size of the final chunk is less than
32 bytes, then RAND_add() fails, whence RAND_load_file() fails
silently for buffer sizes n = k * 1024 + r with r = 1,...,31.

This commit fixes the heap corruption only. The other issues will
be addressed in a separate pull request.

Thanks to Gisle Vanem for reporting this issue.

Fixes #7449

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7455)

(cherry picked from commit 5b4cb385c1)
2018-10-22 14:57:04 +02:00
..
build.info crypto/rand: rename drbg_rand.c to drbg_ctr.c 2018-01-04 11:47:30 +10:00
drbg_ctr.c DRBG: fix reseeding via RAND_add()/RAND_seed() with large input 2018-10-16 22:32:42 +02:00
drbg_lib.c DRBG: fix reseeding via RAND_add()/RAND_seed() with large input 2018-10-16 22:32:42 +02:00
rand_egd.c Update copyright year 2018-05-29 13:16:04 +01:00
rand_err.c DRBG: fix reseeding via RAND_add()/RAND_seed() with large input 2018-10-16 22:32:42 +02:00
rand_lcl.h DRBG: fix reseeding via RAND_add()/RAND_seed() with large input 2018-10-16 22:32:42 +02:00
rand_lib.c RAND_add(): fix heap corruption in error path 2018-10-22 14:57:04 +02:00
rand_unix.c DRBG: fix reseeding via RAND_add()/RAND_seed() with large input 2018-10-16 22:32:42 +02:00
rand_vms.c VMS: only use the high precision on VMS v8.4 and up 2018-09-15 14:59:06 +02:00
rand_win.c crypto/rand: fix some style nit's 2018-10-10 14:02:45 +02:00
randfile.c Use secure_getenv(3) when available. 2018-09-24 11:22:22 +10:00