Software /
code /
prosody
Changeset
7826:7702ce682427
util.crand: Raise hard errors
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 20 Jan 2017 12:23:55 +0100 |
parents | 7825:1dfa5847d49e |
children | 7827:db15e9f6d77f |
files | util-src/crand.c |
diffstat | 1 files changed, 3 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/util-src/crand.c Fri Jan 20 11:33:31 2017 +0100 +++ b/util-src/crand.c Fri Jan 20 12:23:55 2017 +0100 @@ -50,10 +50,8 @@ 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 @@ 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