diff options
author | Kim Alvefur <zash@zash.se> | 2017-12-03 15:42:55 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-12-03 15:42:55 +0100 |
commit | 36ff81d81a339a5b0dbd6e80d0996e1cebfbeb91 (patch) | |
tree | 3eeb5e6a7675b2aea5152323993d13b37a06c3a6 /util-src/crand.c | |
parent | 9ed1cb4bec66b03367c16b9e21a022b70415ba2d (diff) | |
download | prosody-36ff81d81a339a5b0dbd6e80d0996e1cebfbeb91.tar.gz prosody-36ff81d81a339a5b0dbd6e80d0996e1cebfbeb91.zip |
util.crand: Return early if a zero bytes are requested
Diffstat (limited to 'util-src/crand.c')
-rw-r--r-- | util-src/crand.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/util-src/crand.c b/util-src/crand.c index 20871f3e..160ac1f6 100644 --- a/util-src/crand.c +++ b/util-src/crand.c @@ -73,11 +73,15 @@ int Lrandom(lua_State *L) { const size_t len = l; luaL_argcheck(L, l >= 0, 1, "must be > 0"); + if(len == 0) { + lua_pushliteral(L, ""); + return 1; + } + if(len > SMALLBUFSIZ) { buf = lua_newuserdata(L, len); } - #if defined(WITH_GETRANDOM) /* * This acts like a read from /dev/urandom with the exception that it |