summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2014-04-06 23:11:20 +0100
committerDr. Stephen Henson <steve@openssl.org>2014-04-07 19:27:46 +0100
commitcd29ced6de9a5458764d94620588bfb5fa2624ba (patch)
tree3fb21bb9ca2dd0eb0711c0022093b8abe58ee011 /crypto/rand
parent7e840163c06c7692b796a93e3fa85a93136adbb2 (diff)
Return if ssleay_rand_add called with zero num.
Treat a zero length passed to ssleay_rand_add a no op: the existing logic zeroes the md value which is very bad. OpenSSL itself never does this internally and the actual call doesn't make sense as it would be passing zero bytes of entropy. Thanks to Marcus Meissner <meissner@suse.de> for reporting this bug. (cherry picked from commit 5be1ae28ef3c4bdec95b94f14e0e939157be550a)
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/md_rand.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c
index dd29163727..aee1c30b0a 100644
--- a/crypto/rand/md_rand.c
+++ b/crypto/rand/md_rand.c
@@ -198,6 +198,9 @@ static void ssleay_rand_add(const void *buf, int num, double add)
EVP_MD_CTX m;
int do_not_lock;
+ if (!num)
+ return;
+
/*
* (Based on the rand(3) manpage)
*