rand_lib.c: Don't open random devices while cleaning up.
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Tue, 21 Aug 2018 20:51:28 +0000 (22:51 +0200)
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Wed, 22 Aug 2018 08:53:49 +0000 (10:53 +0200)
commitbc420ebea2c5ad813779ac3395f1c5a1083d49c5
tree35585c544e7d2d2fb96c73f16a3bd67976960779
parenta21285b3636a8356f01027416b0cd43b016f58ca
rand_lib.c: Don't open random devices while cleaning up.

Fixes #7022

In pull request #6432 a change was made to keep the handles to the
random devices opened in order to avoid reseeding problems for
applications in chroot environments.

As a consequence, the handles of the random devices were leaked at exit
if the random generator was not used by the application. This happened,
because the call to RAND_set_rand_method(NULL) in rand_cleanup_int()
triggered a call to the call_once function do_rand_init, which opened
the random devices via rand_pool_init().

Thanks to GitHub user @bwelling for reporting this issue.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7023)
crypto/rand/rand_lib.c