summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2012-12-25 22:16:29 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2013-01-06 13:30:04 +0000
commit2a47f02825993e5ade191f8206cb767b0d9fc44c (patch)
tree32242ad0b5fa128a9cc1f296b47df5e0ad4fe0db /src
parent181d9bf8a602a2573d566427803a4c5288a56008 (diff)
Restrict lifetime of $router_name and $transport_name. Bug 308.
The router name is explicitly nulled after the router exits; the transport name is set only in the subprocess it runs in.
Diffstat (limited to 'src')
-rw-r--r--src/src/deliver.c11
-rw-r--r--src/src/route.c7
2 files changed, 12 insertions, 6 deletions
diff --git a/src/src/deliver.c b/src/src/deliver.c
index 55bfa0dd0..e2605ab2c 100644
--- a/src/src/deliver.c
+++ b/src/src/deliver.c
@@ -1871,6 +1871,9 @@ if ((pid = fork()) == 0)
set_process_info("delivering %s to %s using %s", message_id,
addr->local_part, addr->transport->name);
+ /* Setting this global in the subprocess means we need never clear it */
+ transport_name = addr->transport->name;
+
/* If a transport filter has been specified, set up its argument list.
Any errors will get put into the address, and FALSE yielded. */
@@ -2190,8 +2193,6 @@ while (addr_local != NULL)
if (previously_transported(addr, FALSE)) continue;
- transport_name = tp->name;
-
/* There are weird cases where logging is disabled */
disable_logging = tp->disable_logging;
@@ -3532,8 +3533,6 @@ for (delivery_count = 0; addr_remote != NULL; delivery_count++)
if (previously_transported(addr, FALSE)) continue;
- transport_name = tp->name;
-
/* Force failure if the message is too big. */
if (tp->message_size_limit != NULL)
@@ -3859,8 +3858,10 @@ for (delivery_count = 0; addr_remote != NULL; delivery_count++)
int fd = pfd[pipe_write];
host_item *h;
- /* There are weird circumstances in which logging is disabled */
+ /* Setting this global in the subprocess means we need never clear it */
+ transport_name = tp->name;
+ /* There are weird circumstances in which logging is disabled */
disable_logging = tp->disable_logging;
/* Show pids on debug output if parallelism possible */
diff --git a/src/src/route.c b/src/src/route.c
index f8bacf11b..2fee38271 100644
--- a/src/src/route.c
+++ b/src/src/route.c
@@ -1512,7 +1512,6 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
int rc;
DEBUG(D_route) debug_printf("--------> %s router <--------\n", r->name);
- router_name = r->name;
/* Reset any search error message from the previous router. */
@@ -1634,6 +1633,7 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
/* Set the expansion variables now that we have the affixes and the case of
the local part sorted. */
+ router_name = r->name;
deliver_set_expansions(addr);
/* For convenience, the pre-router checks are in a separate function, which
@@ -1641,6 +1641,7 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
if ((rc = check_router_conditions(r, addr, verify, &pw, &error)) != OK)
{
+ router_name = NULL;
if (rc == SKIP) continue;
addr->message = error;
yield = rc;
@@ -1679,6 +1680,7 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
{
DEBUG(D_route)
debug_printf("\"more\"=false: skipping remaining routers\n");
+ router_name = NULL;
r = NULL;
break;
}
@@ -1722,6 +1724,8 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
yield = (r->info->code)(r, addr, pw, verify, paddr_local, paddr_remote,
addr_new, addr_succeed);
+ router_name = NULL;
+
if (yield == FAIL)
{
HDEBUG(D_route) debug_printf("%s router forced address failure\n", r->name);
@@ -1968,6 +1972,7 @@ if (yield == DEFER) {
}
deliver_set_expansions(NULL);
+router_name = NULL;
disable_logging = FALSE;
return yield;
}