提交 d2953e5e 编写于 作者: D Dr. Matthias St. Pierre

drbg_lib: avoid NULL pointer dereference in drbg_add

Found by Coverity Scan
Reviewed-by: NBernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: NRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7511)

(cherry picked from commit 59f90557dd6e35cf72ac72016609d759ac78fcb9)
上级 54dea92f
......@@ -1010,7 +1010,7 @@ static int drbg_add(const void *buf, int num, double randomness)
int ret = 0;
RAND_DRBG *drbg = RAND_DRBG_get0_master();
size_t buflen;
size_t seedlen = rand_drbg_seedlen(drbg);
size_t seedlen;
if (drbg == NULL)
return 0;
......@@ -1018,6 +1018,8 @@ static int drbg_add(const void *buf, int num, double randomness)
if (num < 0 || randomness < 0.0)
return 0;
seedlen = rand_drbg_seedlen(drbg);
buflen = (size_t)num;
if (buflen < seedlen || randomness < (double) seedlen) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册