Skip to content

Commit

Permalink
Merge pull request #4449 from jendis/fix_arc
Browse files Browse the repository at this point in the history
[CritFix] Fix arc signing
  • Loading branch information
vstakhov committed Apr 15, 2023
2 parents e24c536 + 1d7cc87 commit 4e11d4d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/plugins/lua/arc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ local function arc_callback(task)

task:cache_set('arc-sigs', cbdata.sigs)
task:cache_set('arc-seals', cbdata.seals)
task:cache_set('arc-authres', cbdata.ars)

if validation_error then
-- ARC rejection but no strong failure for signing
Expand Down Expand Up @@ -489,7 +490,7 @@ rspamd_config:register_dependency('ARC_CHECK', 'DKIM_CHECK')
local function arc_sign_seal(task, params, header)
local arc_sigs = task:cache_get('arc-sigs')
local arc_seals = task:cache_get('arc-seals')
local arc_auth_results = task:get_header_full('ARC-Authentication-Results') or {}
local arc_auth_results = task:cache_get('arc-authres')
local cur_auth_results
local privkey

Expand Down Expand Up @@ -529,10 +530,12 @@ local function arc_sign_seal(task, params, header)
local cur_idx = 1
if arc_seals then
cur_idx = #arc_seals + 1
for i = (cur_idx - 1), 1, (-1) do
-- We use the cached version per each ARC-* header field individually, already sorted by instance
-- value in ascending order
for i = 1, #arc_seals, 1 do
if arc_auth_results[i] then
local s = dkim_canonicalize('ARC-Authentication-Results',
arc_auth_results[i].value)
arc_auth_results[i].raw_header)
sha_ctx:update(s)
lua_util.debugm(N, task, 'update signature with header: %s', s)
end
Expand Down

0 comments on commit 4e11d4d

Please sign in to comment.