rand: Add missing check for rand_get_global
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Tue, 15 Feb 2022 09:45:04 +0000 (17:45 +0800)
committerDr. Matthias St. Pierre <matthias.st.pierre@ncp-e.com>
Sun, 20 Feb 2022 12:09:27 +0000 (13:09 +0100)
commit09dca557332a2187598932388ac7bd7bbf16172b
treedff4964a807978d6677285bb2e7b17225a30b834
parentd43597c718dd6e4f2b18d5cec1eb791503a18988
rand: Add missing check for rand_get_global

As the potential failure of the rand_get_global(),
for example fail to get lock, 'dgbl' could be NULL
pointer and be dereferenced later.
Therefore, it should be better to check it and return
error if fails, like RAND_get0_primary() and other callers.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/17690)
crypto/rand/rand_lib.c