aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-05-26 19:41:58 +0200
committerKim Alvefur <zash@zash.se>2019-05-26 19:41:58 +0200
commit48d6fa1aa122769a56d81c57276e46b27b63f101 (patch)
tree11a618b505748faf115684e27aa45b2a622e80a9 /util
parent61d02f359982574f857674bc314ac121f2735189 (diff)
parenta6e44a24a0afdfb34a74d15a98b3a1f05e54cf9a (diff)
downloadprosody-48d6fa1aa122769a56d81c57276e46b27b63f101.tar.gz
prosody-48d6fa1aa122769a56d81c57276e46b27b63f101.zip
Merge 0.11->trunk
Diffstat (limited to 'util')
-rw-r--r--util/random.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/util/random.lua b/util/random.lua
index d8a84514..6782d7fa 100644
--- a/util/random.lua
+++ b/util/random.lua
@@ -12,7 +12,15 @@ 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
+ if err then
+ error("Unable to retrieve data from secure random number generator (/dev/urandom): "..tostring(err));
+ else
+ error("Secure random number generator (/dev/urandom) returned an end-of-file condition");
+ end
+ end
+ return data;
end
if not urandom then