Software /
code /
prosody
Comparison
util-src/crypto.c @ 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 |
parent | 12714:82bca7191f13 |
child | 12735:445f7bd6ffc4 |
comparison
equal
deleted
inserted
replaced
12714:82bca7191f13 | 12715:5dd00f806e32 |
---|---|
483 | 483 |
484 ECDSA_SIG_set0(sig, r, s); | 484 ECDSA_SIG_set0(sig, r, s); |
485 | 485 |
486 luaL_buffinit(L, &sigbuf); | 486 luaL_buffinit(L, &sigbuf); |
487 | 487 |
488 // COMPAT w/ Lua 5.1 | 488 unsigned char *buffer = (unsigned char*)luaL_prepbuffsize(&sigbuf, rlen+slen+32); |
489 #if LUAL_BUFFERSIZE < 128 | |
490 #error Configured LUAL_BUFFERSIZE is too small for this operation | |
491 #endif | |
492 | |
493 unsigned char *buffer = (unsigned char*)luaL_prepbuffer(&sigbuf); | |
494 int len = i2d_ECDSA_SIG(sig, &buffer); | 489 int len = i2d_ECDSA_SIG(sig, &buffer); |
495 luaL_addsize(&sigbuf, len); | 490 luaL_addsize(&sigbuf, len); |
496 luaL_pushresult(&sigbuf); | 491 luaL_pushresult(&sigbuf); |
497 | 492 |
498 ECDSA_SIG_free(sig); | 493 ECDSA_SIG_free(sig); |