From 7b60dc479487ba2c2ad36e5abefb862fd15cf5e4 Mon Sep 17 00:00:00 2001 From: Bruno Silvestre Date: Thu, 16 Feb 2023 09:41:35 -0300 Subject: [PATCH] Fix psk_len type, do not check string again --- src/context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/context.c b/src/context.c index 8e2b736..9e36f1e 100644 --- a/src/context.c +++ b/src/context.c @@ -713,7 +713,7 @@ static int set_alpn_cb(lua_State *L) */ static unsigned int server_psk_cb(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len) { - int psk_len; + size_t psk_len; const char *ret_psk; SSL_CTX *ctx = SSL_get_SSL_CTX(ssl); p_context pctx = (p_context)SSL_CTX_get_app_data(ctx); @@ -733,7 +733,7 @@ static unsigned int server_psk_cb(SSL *ssl, const char *identity, unsigned char return 0; } - ret_psk = luaL_checklstring(L, -1, &psk_len); + ret_psk = luaL_tolstring(L, -1, &psk_len); memcpy(psk, ret_psk, (psk_len > max_psk_len) ? max_psk_len : psk_len); lua_pop(L, 2);