diff options
author | Kim Alvefur <zash@zash.se> | 2022-07-11 17:11:38 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-07-11 17:11:38 +0200 |
commit | 62438f482ed8cf1c361dc4904baefcd893998403 (patch) | |
tree | 4bfe84f658848aa56d9c23126c78a054b126b611 /util-src | |
parent | e893bbf6817ff4193d9639afc40143fd792c9a4b (diff) | |
download | prosody-62438f482ed8cf1c361dc4904baefcd893998403.tar.gz prosody-62438f482ed8cf1c361dc4904baefcd893998403.zip |
util.crypto: Use Lua 5.2 API for predictable buffer size
In Lua 5.3 LUAL_BUFFERSIZE is a macro computed from sizeof and is thus
not known at pre-processing time, so this does not work.
Since Lua 5.1 is no longer supported, we can use luaL_prepbuffsize()
which is available from Lua 5.2
Diffstat (limited to 'util-src')
-rw-r--r-- | util-src/crypto.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/util-src/crypto.c b/util-src/crypto.c index 0f4edb51..c5ecf9ab 100644 --- a/util-src/crypto.c +++ b/util-src/crypto.c @@ -485,12 +485,7 @@ static int Lbuild_ecdsa_signature(lua_State *L) { luaL_buffinit(L, &sigbuf); - // COMPAT w/ Lua 5.1 - #if LUAL_BUFFERSIZE < 128 - #error Configured LUAL_BUFFERSIZE is too small for this operation - #endif - - unsigned char *buffer = (unsigned char*)luaL_prepbuffer(&sigbuf); + unsigned char *buffer = (unsigned char*)luaL_prepbuffsize(&sigbuf, rlen+slen+32); int len = i2d_ECDSA_SIG(sig, &buffer); luaL_addsize(&sigbuf, len); luaL_pushresult(&sigbuf); |