Software /
code /
prosody
Changeset
12715:5dd00f806e32
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
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 11 Jul 2022 17:11:38 +0200 |
parents | 12714:82bca7191f13 |
children | 12716:0b68b021ce46 |
files | util-src/crypto.c |
diffstat | 1 files changed, 1 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/util-src/crypto.c Mon Jul 11 17:01:55 2022 +0200 +++ b/util-src/crypto.c Mon Jul 11 17:11:38 2022 +0200 @@ -485,12 +485,7 @@ 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);