aboutsummaryrefslogtreecommitdiffstats
path: root/util/random.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-05-21 08:52:21 +0200
committerKim Alvefur <zash@zash.se>2019-05-21 08:52:21 +0200
commit8ceccabe00d91193fa3b940b3c9b9d65727b8a0d (patch)
tree90a2d9a17501e73f285579e5f7a814fcb33cd335 /util/random.lua
parentf51f1f1375c3b1ff58aaa1f8b9082b69b1ef95d7 (diff)
downloadprosody-8ceccabe00d91193fa3b940b3c9b9d65727b8a0d.tar.gz
prosody-8ceccabe00d91193fa3b940b3c9b9d65727b8a0d.zip
util.random: Throw different error for EOL condition
Diffstat (limited to 'util/random.lua')
-rw-r--r--util/random.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/random.lua b/util/random.lua
index 51f2747d..6782d7fa 100644
--- a/util/random.lua
+++ b/util/random.lua
@@ -14,7 +14,11 @@ local urandom, urandom_err = io.open("/dev/urandom", "r");
local function bytes(n)
local data, err = urandom:read(n);
if not data then
- error("Unable to retrieve data from secure random number generator (/dev/urandom): "..tostring(err));
+ 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