aboutsummaryrefslogtreecommitdiffstats
path: root/util-src/crand.c
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-01-20 12:23:55 +0100
committerKim Alvefur <zash@zash.se>2017-01-20 12:23:55 +0100
commit13f287acb9eb066e95bcbd0faf1db07f5aca953d (patch)
tree8dd97596d71c5ccb961923dce1fba2a7fc94203e /util-src/crand.c
parent8e052e0857a2b62c33271334470ff529f9b76a85 (diff)
downloadprosody-13f287acb9eb066e95bcbd0faf1db07f5aca953d.tar.gz
prosody-13f287acb9eb066e95bcbd0faf1db07f5aca953d.zip
util.crand: Raise hard errors
Diffstat (limited to 'util-src/crand.c')
-rw-r--r--util-src/crand.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/util-src/crand.c b/util-src/crand.c
index 6b9dc726..ab16d8d8 100644
--- a/util-src/crand.c
+++ b/util-src/crand.c
@@ -50,10 +50,8 @@ int Lrandom(lua_State *L) {
ret = getrandom(buf, len, 0);
if(ret < 0) {
- lua_pushnil(L);
lua_pushstring(L, strerror(errno));
- lua_pushinteger(L, errno);
- return 3;
+ return lua_error(L);
}
#elif defined(WITH_ARC4RANDOM)
@@ -65,10 +63,8 @@ int Lrandom(lua_State *L) {
if(ret == 1) {
ret = len;
} else {
- lua_pushnil(L);
- lua_pushstring(L, "failed");
- /* lua_pushinteger(L, ERR_get_error()); */
- return 2;
+ lua_pushstring(L, "RAND_bytes() failed");
+ return lua_error(L);
}
#endif