aboutsummaryrefslogtreecommitdiffstats
path: root/util-src
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-03-01 02:38:05 +0100
committerKim Alvefur <zash@zash.se>2017-03-01 02:38:05 +0100
commit55ba289bedc1580f49af034b8a849958b698de77 (patch)
tree9e8179e3cdc021aa83812cf4bbdb4fd0d9cbc814 /util-src
parentda6eaea135e293573a6aeaf651ac49288e47e47f (diff)
parent9e586ac1dfdf187a7a5d5f80a818c92b13b16f0c (diff)
downloadprosody-55ba289bedc1580f49af034b8a849958b698de77.tar.gz
prosody-55ba289bedc1580f49af034b8a849958b698de77.zip
Merge 0.10->trunk
Diffstat (limited to 'util-src')
-rw-r--r--util-src/crand.c10
-rw-r--r--util-src/pposix.c2
2 files changed, 7 insertions, 5 deletions
diff --git a/util-src/crand.c b/util-src/crand.c
index cc2047eb..f3fa00ea 100644
--- a/util-src/crand.c
+++ b/util-src/crand.c
@@ -67,6 +67,11 @@ int Lrandom(lua_State *L) {
arc4random_buf(buf, len);
ret = len;
#elif defined(WITH_OPENSSL)
+ if(!RAND_status()) {
+ lua_pushliteral(L, "OpenSSL PRNG not seeded");
+ return lua_error(L);
+ }
+
ret = RAND_bytes(buf, len);
if(ret == 1) {
@@ -87,6 +92,7 @@ int luaopen_util_crand(lua_State *L) {
#if (LUA_VERSION_NUM > 501)
luaL_checkversion(L);
#endif
+
lua_newtable(L);
lua_pushcfunction(L, Lrandom);
lua_setfield(L, -2, "bytes");
@@ -100,10 +106,6 @@ int luaopen_util_crand(lua_State *L) {
#endif
lua_setfield(L, -2, "_source");
-#if defined(WITH_OPENSSL) && defined(_WIN32)
- /* TODO Do we need to seed this on Windows? */
-#endif
-
return 1;
}
diff --git a/util-src/pposix.c b/util-src/pposix.c
index 5e21be56..10edbd71 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -615,7 +615,7 @@ int lc_getrlimit(lua_State *L) {
return 2;
}
} else {
- /* Unsupported resoucrce. Sorry I'm pretty limited by POSIX standard. */
+ /* Unsupported resource. Sorry I'm pretty limited by POSIX standard. */
lua_pushboolean(L, 0);
lua_pushstring(L, "invalid-resource");
return 2;