git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
GnuTLS: fix hanging callout connections
[exim.git]
/
src
/
src
/
dkim.c
diff --git
a/src/src/dkim.c
b/src/src/dkim.c
index a410ed55bbcbfe2734b12493c784bc0c67429f8f..5c9d2279e165767715385013862a330b81023c9d 100644
(file)
--- a/
src/src/dkim.c
+++ b/
src/src/dkim.c
@@
-37,29
+37,28
@@
static const uschar * dkim_collect_error = NULL;
-/*XXX the caller only uses the first record if we return multiple.
+/* Look up the DKIM record in DNS for the given hostname.
+Will use the first found if there are multiple.
+The return string is tainted, having come from off-site.
*/
uschar *
*/
uschar *
-dkim_exim_query_dns_txt(uschar * name)
+dkim_exim_query_dns_txt(
const
uschar * name)
{
{
-/*XXX need to always alloc the dnsa, from tainted mem.
-Then, we hope, the answers will be tainted */
-
-dns_answer dnsa;
+dns_answer * dnsa = store_get_dns_answer();
dns_scan dnss;
rmark reset_point = store_mark();
gstring * g = NULL;
lookup_dnssec_authenticated = NULL;
dns_scan dnss;
rmark reset_point = store_mark();
gstring * g = NULL;
lookup_dnssec_authenticated = NULL;
-if (dns_lookup(
&
dnsa, name, T_TXT, NULL) != DNS_SUCCEED)
+if (dns_lookup(dnsa, name, T_TXT, NULL) != DNS_SUCCEED)
return NULL; /*XXX better error detail? logging? */
/* Search for TXT record */
return NULL; /*XXX better error detail? logging? */
/* Search for TXT record */
-for (dns_record * rr = dns_next_rr(
&
dnsa, &dnss, RESET_ANSWERS);
+for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_ANSWERS);
rr;
rr;
- rr = dns_next_rr(
&
dnsa, &dnss, RESET_NEXT))
+ rr = dns_next_rr(dnsa, &dnss, RESET_NEXT))
if (rr->type == T_TXT)
{
int rr_offset = 0;
if (rr->type == T_TXT)
{
int rr_offset = 0;
@@
-96,6
+95,8
@@
return NULL; /*XXX better error detail? logging? */
void
dkim_exim_init(void)
{
void
dkim_exim_init(void)
{
+if (f.dkim_init_done) return;
+f.dkim_init_done = TRUE;
pdkim_init();
}
pdkim_init();
}
@@
-104,6
+105,8
@@
pdkim_init();
void
dkim_exim_verify_init(BOOL dot_stuffing)
{
void
dkim_exim_verify_init(BOOL dot_stuffing)
{
+dkim_exim_init();
+
/* There is a store-reset between header & body reception
so cannot use the main pool. Any allocs done by Exim
memory-handling must use the perm pool. */
/* There is a store-reset between header & body reception
so cannot use the main pool. Any allocs done by Exim
memory-handling must use the perm pool. */
@@
-570,6
+573,8
@@
void
dkim_exim_sign_init(void)
{
int old_pool = store_pool;
dkim_exim_sign_init(void)
{
int old_pool = store_pool;
+
+dkim_exim_init();
store_pool = POOL_MAIN;
pdkim_init_context(&dkim_sign_ctx, FALSE, &dkim_exim_query_dns_txt);
store_pool = old_pool;
store_pool = POOL_MAIN;
pdkim_init_context(&dkim_sign_ctx, FALSE, &dkim_exim_query_dns_txt);
store_pool = old_pool;
@@
-784,14
+789,15
@@
CLEANUP:
pk_bad:
log_write(0, LOG_MAIN|LOG_PANIC,
pk_bad:
log_write(0, LOG_MAIN|LOG_PANIC,
- "DKIM: signing failed: %.100s", pdkim_errstr(pdkim_rc));
+ "DKIM: signing failed: %.100s", pdkim_errstr(pdkim_rc));
bad:
sigbuf = NULL;
goto CLEANUP;
expand_bad:
bad:
sigbuf = NULL;
goto CLEANUP;
expand_bad:
- log_write(0, LOG_MAIN | LOG_PANIC, "failed to expand %s: %s",
- errwhen, expand_string_message);
+ *errstr = string_sprintf("failed to expand %s: %s",
+ errwhen, expand_string_message);
+ log_write(0, LOG_MAIN | LOG_PANIC, "%s", *errstr);
goto bad;
}
goto bad;
}