gsize len;
gint header_canon_type;
gint body_canon_type;
+ gboolean is_sign;
GPtrArray *hlist;
GHashTable *htable; /* header -> count mapping */
EVP_MD_CTX *headers_hash;
(gint)rh->raw_len, rh->raw_value);
}
else {
+ if (ctx->is_sign && (rh->type & RSPAMD_HEADER_FROM)) {
+ /* Special handling of the From handling when rewrite is done */
+ gboolean has_rewrite = FALSE;
+ guint i;
+ struct rspamd_email_address *addr;
+
+ PTR_ARRAY_FOREACH (task->from_mime, i, addr) {
+ if ((addr->flags & RSPAMD_EMAIL_ADDR_ORIGINAL)
+ && !(addr->flags & RSPAMD_EMAIL_ADDR_ALIASED)) {
+ has_rewrite = TRUE;
+ }
+ }
+
+ if (has_rewrite) {
+ PTR_ARRAY_FOREACH (task->from_mime, i, addr) {
+ if (!(addr->flags & RSPAMD_EMAIL_ADDR_ORIGINAL)) {
+ if (!rspamd_dkim_canonize_header_relaxed (ctx, addr->raw,
+ header_name, FALSE)) {
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+ }
+ }
+ }
+
if (!rspamd_dkim_canonize_header_relaxed (ctx, rh->value,
header_name, FALSE)) {
return FALSE;
nctx->common.header_canon_type = headers_canon;
nctx->common.body_canon_type = body_canon;
nctx->common.type = type;
+ nctx->common.is_sign = TRUE;
if (type != RSPAMD_DKIM_ARC_SEAL) {
if (!rspamd_dkim_parse_hdrlist_common (&nctx->common, headers,
lua_gettable (L, pos);
if (lua_type (L, -1) == LUA_TSTRING) {
+ gchar *cpy;
p = lua_tolstring (L, -1, &len);
- addr->raw = (const gchar *)rspamd_mempool_alloc (task->task_pool, len);
- memcpy ((gchar *)addr->raw, p, len);
+ cpy = rspamd_mempool_alloc (task->task_pool, len + 1);
+ memcpy (cpy, p, len);
+ cpy[len] = '\0';
addr->raw_len = len;
+ addr->raw = cpy;
}
else {
/* Construct raw addr */