From d21acaaf6689a38d60a533872730f2bae25a5281 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 20 Jan 2017 12:23:55 +0100 Subject: util.crand: Raise hard errors --- util-src/crand.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'util-src/crand.c') 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 -- cgit v1.2.3