Fix a potential crash in rand_unix.c
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 6 Sep 2019 19:54:13 +0000 (21:54 +0200)
committerMatt Caswell <matt@openssl.org>
Tue, 10 Sep 2019 09:03:04 +0000 (10:03 +0100)
commit79f5e2f4b9d9886d1b0da09c2eb3e397bcf82876
tree469d37bbcd17df59fe6ac70e6d6e1f5382217d19
parent1d36536457c14c92a2e728e8499260f396bd4657
Fix a potential crash in rand_unix.c

Due to the dynamic allocation that was added to rand_pool_add_begin
this function could now return a null pointer where it was previously
guaranteed to succeed. But the return value of this function does
not need to be checked by design.

Move rand_pool_grow from rand_pool_add_begin to rand_pool_bytes_needed.
Make an allocation error persistent to avoid falling back to less secure
or blocking entropy sources.

Fixes: a6a66e4511ee ("Make rand_pool buffers more dynamic in their sizing.")

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9687)

(cherry picked from commit fa3eb248e29ca8031e6a14e8a2c6f3cd58b5450e)
crypto/rand/rand_lib.c