Skip to content

Commit

Permalink
Return if ssleay_rand_add called with zero num.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
snhenson committed Apr 7, 2014
1 parent 96db902 commit 5be1ae2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crypto/rand/md_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*
Expand Down

0 comments on commit 5be1ae2

Please sign in to comment.