aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-01 14:03:23 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-01 14:03:23 +0000
commit831de79b9444275850bc56450790df630f22758a (patch)
tree1a3abf4b778af9a6757be1918defe3f3e98b8444 /src
parent5569e44d151ae856c5f80d9e9ee2c7034cb42e25 (diff)
downloadrspamd-831de79b9444275850bc56450790df630f22758a.tar.gz
rspamd-831de79b9444275850bc56450790df630f22758a.zip
[Project] Fix several issues with dkim check results
Diffstat (limited to 'src')
-rw-r--r--src/libserver/dkim.c12
-rw-r--r--src/lua/lua_task.c3
2 files changed, 10 insertions, 5 deletions
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index e952ccb22..5047531d7 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -36,6 +36,8 @@
#define DKIM_CANON_DEFAULT DKIM_CANON_SIMPLE
+#define RSPAMD_SHORT_BH_LEN 8
+
/* Params */
enum rspamd_dkim_param_type {
DKIM_PARAM_UNKNOWN = -1,
@@ -111,6 +113,7 @@ enum rspamd_arc_seal_cv {
RSPAMD_ARC_PASS
};
+
struct rspamd_dkim_context_s {
struct rspamd_dkim_common_ctx common;
rspamd_mempool_t *pool;
@@ -123,6 +126,7 @@ struct rspamd_dkim_context_s {
gchar *domain;
gchar *selector;
gint8 *b;
+ gchar *short_b;
gint8 *bh;
gchar *dns_key;
enum rspamd_arc_seal_cv cv;
@@ -264,6 +268,8 @@ rspamd_dkim_parse_signature (rspamd_dkim_context_t * ctx,
GError **err)
{
ctx->b = rspamd_mempool_alloc0 (ctx->pool, len);
+ ctx->short_b = rspamd_mempool_alloc0 (ctx->pool, RSPAMD_SHORT_BH_LEN + 1);
+ rspamd_strlcpy (ctx->short_b, param, MIN (len, RSPAMD_SHORT_BH_LEN + 1));
(void)rspamd_cryptobox_base64_decode (param, len, ctx->b, &ctx->blen);
return TRUE;
@@ -2283,9 +2289,8 @@ rspamd_dkim_check (rspamd_dkim_context_t *ctx,
res->selector = ctx->selector;
res->domain = ctx->domain;
res->fail_reason = NULL;
- res->short_b = rspamd_encode_base64 (ctx->b, 4, 0, NULL);
+ res->short_b = ctx->short_b;
res->rcode = DKIM_CONTINUE;
- rspamd_mempool_add_destructor (task->task_pool, g_free, (gpointer)res->short_b);
if (!body_start) {
res->rcode = DKIM_ERROR;
@@ -2530,8 +2535,7 @@ rspamd_dkim_create_result (rspamd_dkim_context_t *ctx,
res->selector = ctx->selector;
res->domain = ctx->domain;
res->fail_reason = NULL;
- res->short_b = rspamd_encode_base64 (ctx->b, 4, 0, NULL);
- rspamd_mempool_add_destructor (task->task_pool, g_free, (gpointer)res->short_b);
+ res->short_b = ctx->short_b;
return res;
}
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 18ec67305..6f4923dc8 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -562,6 +562,7 @@ LUA_FUNCTION_DEF (task, get_archives);
* * `domain` - dkim domain
* * `selector` - dkim selector
* * `bhash` - short version of b tag (8 base64 symbols)
+ * * `fail_reason` - reason of failure (if applicable)
* @return {list of maps} dkim check results
*/
LUA_FUNCTION_DEF (task, get_dkim_results);
@@ -3484,7 +3485,7 @@ lua_task_get_dkim_results (lua_State *L)
}
if (res->fail_reason) {
- rspamd_lua_table_set (L, "fail", res->fail_reason);
+ rspamd_lua_table_set (L, "fail_reason", res->fail_reason);
}
lua_rawseti (L, -2, i + 1);