X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/1eedc10f0c518d1878a5d94ff17b84cad233b23e..286b9d5fa4344de72fe6575fa089237fd7dbb56f:/src/src/dkim.c diff --git a/src/src/dkim.c b/src/src/dkim.c index 867d45647..c7bf64152 100644 --- a/src/src/dkim.c +++ b/src/src/dkim.c @@ -58,7 +58,6 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); if (rr->type == T_TXT) { int rr_offset = 0; - int answer_offset = 0; /* Copy record content to the answer buffer */ @@ -74,7 +73,7 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); } /* check if this looks like a DKIM record */ - if (strncmp(g->s, "v=", 2) != 0 || strncasecmp(g->s, "v=dkim", 6) == 0) + if (Ustrncmp(g->s, "v=", 2) != 0 || strncasecmp(CS g->s, "v=dkim", 6) == 0) { store_reset(g->s + g->ptr + 1); return string_from_gstring(g); @@ -269,7 +268,7 @@ dkim_exim_verify_finish(void) pdkim_signature * sig; int rc; gstring * g = NULL; -const uschar * errstr; +const uschar * errstr = NULL; store_pool = POOL_PERM; @@ -292,12 +291,8 @@ dkim_collect_input = FALSE; /* Finish DKIM operation and fetch link to signatures chain */ rc = pdkim_feed_finish(dkim_verify_ctx, &dkim_signatures, &errstr); -if (rc != PDKIM_OK) - { - log_write(0, LOG_MAIN, "DKIM: validation error: %.100s%s%s", pdkim_errstr(rc), - errstr ? ": " : "", errstr ? errstr : US""); - goto out; - } +if (rc != PDKIM_OK && errstr) + log_write(0, LOG_MAIN, "DKIM: validation error: %s", errstr); /* Build a colon-separated list of signing domains (and identities, if present) in dkim_signers */ @@ -711,6 +706,9 @@ while ((dkim_signing_domain = string_nextinlist(&dkim_domain, &sep, NULL, 0))) pdkim_canon, pdkim_canon, -1, 0, 0); + if (!pdkim_set_bodyhash(&ctx, sig)) + goto bad; + if (!ctx.sig) /* link sig to context chain */ ctx.sig = sig; else @@ -728,7 +726,7 @@ if (!ctx.sig) goto CLEANUP; } -if (prefix && (pdkim_feed(&ctx, prefix, Ustrlen(prefix))) != PDKIM_OK) +if (prefix && (pdkim_rc = pdkim_feed(&ctx, prefix, Ustrlen(prefix))) != PDKIM_OK) goto pk_bad; if (lseek(fd, off, SEEK_SET) < 0)