diff options
author | Kim Alvefur <zash@zash.se> | 2019-05-18 17:28:21 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-05-18 17:28:21 +0200 |
commit | b0459a771b38a2788949810aeb4a06ad32110e15 (patch) | |
tree | cd21fcbaaf5001bbb68036624fdcc975e7f7bee9 /util | |
parent | 15259577d158d275cea8658d2d6bb5bc50be7738 (diff) | |
download | prosody-b0459a771b38a2788949810aeb4a06ad32110e15.tar.gz prosody-b0459a771b38a2788949810aeb4a06ad32110e15.zip |
util.random: Handle unlikely read errors from /dev/urandom (see #1313)
Diffstat (limited to 'util')
-rw-r--r-- | util/random.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/util/random.lua b/util/random.lua index d8a84514..8ae06b49 100644 --- a/util/random.lua +++ b/util/random.lua @@ -12,7 +12,11 @@ if ok then return crand; end local urandom, urandom_err = io.open("/dev/urandom", "r"); local function bytes(n) - return urandom:read(n); + local data, err = urandom:read(n); + if not data then + error("Unable to retrieve data from secure random number generator (/dev/urandom): "..err); + end + return data; end if not urandom then |