aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_rsa.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-23 16:32:32 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-23 16:33:06 +0100
commit03792148a1147f1cada5e9d5980c9d09637817ea (patch)
treea036a7f638c9edddfe67983b1abb9f362162d4de /src/lua/lua_rsa.c
parent01036d24ca7794ac7ad7be407798806f4eac54ce (diff)
downloadrspamd-03792148a1147f1cada5e9d5980c9d09637817ea.tar.gz
rspamd-03792148a1147f1cada5e9d5980c9d09637817ea.zip
[CritFix] Fix \0 processing when doing RSA sign
Diffstat (limited to 'src/lua/lua_rsa.c')
-rw-r--r--src/lua/lua_rsa.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lua/lua_rsa.c b/src/lua/lua_rsa.c
index 39433a167..58607f92c 100644
--- a/src/lua/lua_rsa.c
+++ b/src/lua/lua_rsa.c
@@ -609,14 +609,15 @@ lua_rsa_verify_memory (lua_State *L)
RSA *rsa;
rspamd_fstring_t *signature;
const gchar *data;
+ gsize sz;
gint ret;
rsa = lua_check_rsa_pubkey (L, 1);
signature = lua_check_rsa_sign (L, 2);
- data = luaL_checkstring (L, 3);
+ data = luaL_checklstring (L, 3, &sz);
if (rsa != NULL && signature != NULL && data != NULL) {
- ret = RSA_verify (NID_sha256, data, strlen (data),
+ ret = RSA_verify (NID_sha256, data, sz,
signature->str, signature->len, rsa);
if (ret == 0) {
@@ -651,14 +652,15 @@ lua_rsa_sign_memory (lua_State *L)
RSA *rsa;
rspamd_fstring_t *signature, **psig;
const gchar *data;
+ gsize sz;
gint ret;
rsa = lua_check_rsa_privkey (L, 1);
- data = luaL_checkstring (L, 2);
+ data = luaL_checklstring (L, 2, &sz);
if (rsa != NULL && data != NULL) {
signature = rspamd_fstring_sized_new (RSA_size (rsa));
- ret = RSA_sign (NID_sha256, data, strlen (data),
+ ret = RSA_sign (NID_sha256, data, sz,
signature->str, (guint *)&signature->len, rsa);
if (ret != 1) {