diff options
author | Phil Pennock <pdp@exim.org> | 2011-02-21 01:09:25 -0500 |
---|---|---|
committer | Phil Pennock <pdp@exim.org> | 2011-02-21 01:11:23 -0500 |
commit | bc4bc4c581f45f7afae0e06e5279026dae7e519a (patch) | |
tree | 03d34e5f493b9e87c35fb2cf626b2372ab2101ad | |
parent | 82b199b94da8ad79db922e34e2fc457eed4ad5ad (diff) |
DKIM multiple signature generation fix.
Patch from Uwe Doering, sign-off by Michael Haardt.
fixes bug 1019
-rw-r--r-- | doc/doc-txt/ChangeLog | 3 | ||||
-rw-r--r-- | src/src/dkim.c | 22 |
2 files changed, 20 insertions, 5 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 3764a88a1..1188810ba 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -69,6 +69,9 @@ PP/12 Bugzilla 1056: Improved spamd server selection. PP/13 Bugzilla 1086: Deal with maildir quota file races. Based on patch from Heiko Schlittermann. +PP/14 Bugzilla 1019: DKIM multiple signature generation fix. + Patch from Uwe Doering, sign-off by Michael Haardt. + Exim version 4.74 ----------------- diff --git a/src/src/dkim.c b/src/src/dkim.c index 2a06dee92..e25ff8c85 100644 --- a/src/src/dkim.c +++ b/src/src/dkim.c @@ -397,6 +397,9 @@ uschar *dkim_exim_sign(int dkim_fd, uschar *dkim_private_key_expanded; pdkim_ctx *ctx = NULL; uschar *rc = NULL; + uschar *sigbuf = NULL; + int sigsize = 0; + int sigptr = 0; pdkim_signature *signature; int pdkim_canon; int pdkim_rc; @@ -405,6 +408,8 @@ uschar *dkim_exim_sign(int dkim_fd, int save_errno = 0; int old_pool = store_pool; + store_pool = POOL_MAIN; + dkim_domain = expand_string(dkim_domain); if (dkim_domain == NULL) { /* expansion error, do not send message. */ @@ -484,8 +489,7 @@ uschar *dkim_exim_sign(int dkim_fd, (Ustrcmp(dkim_private_key_expanded,"0") == 0) || (Ustrcmp(dkim_private_key_expanded,"false") == 0) ) { /* don't sign, but no error */ - rc = US""; - goto CLEANUP; + continue; } if (dkim_private_key_expanded[0] == '/') { @@ -522,6 +526,7 @@ uschar *dkim_exim_sign(int dkim_fd, 0, 0); + lseek(dkim_fd, 0, SEEK_SET); while((sread = read(dkim_fd,&buf,4096)) > 0) { if (pdkim_feed(ctx,buf,sread) != PDKIM_OK) { rc = NULL; @@ -539,17 +544,24 @@ uschar *dkim_exim_sign(int dkim_fd, pdkim_rc = pdkim_feed_finish(ctx,&signature); if (pdkim_rc != PDKIM_OK) { log_write(0, LOG_MAIN|LOG_PANIC, "DKIM: signing failed (RC %d)", pdkim_rc); + rc = NULL; goto CLEANUP; } - rc = store_get(strlen(signature->signature_header)+3); - Ustrcpy(rc,US signature->signature_header); - Ustrcat(rc,US"\r\n"); + sigbuf = string_append(sigbuf, &sigsize, &sigptr, 2, + US signature->signature_header, + US"\r\n"); pdkim_free_ctx(ctx); ctx = NULL; } + if (sigbuf != NULL) { + sigbuf[sigptr] = '\0'; + rc = sigbuf; + } else + rc = US""; + CLEANUP: if (ctx != NULL) pdkim_free_ctx(ctx); |