Software /
code /
prosody
Diff
util/random.lua @ 10014:5d2f7144fa12 0.11
util.random: Handle unlikely read errors from /dev/urandom (see #1313)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 18 May 2019 17:28:21 +0200 |
parent | 8243:292f61d9d30a |
child | 10015:8297408db58b |
line wrap: on
line diff
--- a/util/random.lua Sat May 18 17:45:20 2019 +0200 +++ b/util/random.lua Sat May 18 17:28:21 2019 +0200 @@ -12,7 +12,11 @@ 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