From 424a1c6396fa95a4a5fb9ff2e184929f53d37032 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Mon, 19 Dec 2005 12:25:21 +0000 Subject: [PATCH] Another bug in autoreply with bad address. --- doc/doc-txt/ChangeLog | 10 +++++++++- src/src/deliver.c | 20 +++++++++++++++++--- src/src/filter.c | 13 +++++++++---- src/src/structs.h | 3 ++- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index e59a3f541..7122575df 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.279 2005/12/15 18:09:55 jetmore Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.280 2005/12/19 12:25:21 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -52,6 +52,14 @@ JJ/01 exipick: fixed bug where -b (brief) output option showed "Vars:" JJ/02 exipick: Added support for new ACL variable spool format introduced in 4.61-PH/06 +PH/10 Fixed another bug related to PH/04 above: if an incoming message had a + syntactically invalid From: or Reply-to: line, and a filter used this to + generate an autoreply, and therefore failed to obtain an address for the + autoreply, Exim could try to deliver to a non-existent relative file + name, causing unrelated and misleading errors. What now happens is that + it logs this as a hard delivery error, but does not attempt to create a + bounce message. + Exim version 4.60 ----------------- diff --git a/src/src/deliver.c b/src/src/deliver.c index 655ec9b8e..c616752ff 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/deliver.c,v 1.24 2005/12/12 11:41:50 ph10 Exp $ */ +/* $Cambridge: exim/src/src/deliver.c,v 1.25 2005/12/19 12:25:21 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -5175,7 +5175,20 @@ while (addr_new != NULL) /* Loop until all addresses dealt with */ if (testflag(addr, af_pfr)) { - int offset = testflag(addr->parent, af_homonym)? 3:0; + /* If an autoreply in a filter could not generate a syntactically valid + address, give up forthwith. Set af_ignore_error so that we don't try to + generate a bounce. */ + + if (testflag(addr, af_bad_reply)) + { + addr->basic_errno = ERRNO_BADADDRESS2; + addr->local_part = addr->address; + addr->message = + US"filter autoreply generated syntactically invalid recipient"; + setflag(addr, af_ignore_error); + (void)post_process_one(addr, FAIL, LOG_MAIN, DTYPE_ROUTER, 0); + continue; /* with the next new address */ + } /* If two different users specify delivery to the same pipe or file or autoreply, there should be two different deliveries, so build a unique @@ -5183,7 +5196,8 @@ while (addr_new != NULL) /* Loop until all addresses dealt with */ duplicate testing and recording delivery, and also for retrying. */ addr->unique = - string_sprintf("%s:%s", addr->address, addr->parent->unique + offset); + string_sprintf("%s:%s", addr->address, addr->parent->unique + + (testflag(addr->parent, af_homonym)? 3:0)); addr->address_retry_key = addr->domain_retry_key = string_sprintf("T:%s", addr->unique); diff --git a/src/src/filter.c b/src/src/filter.c index 1773a8f2f..e3d43b416 100644 --- a/src/src/filter.c +++ b/src/src/filter.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/filter.c,v 1.7 2005/11/11 10:02:04 ph10 Exp $ */ +/* $Cambridge: exim/src/src/filter.c,v 1.8 2005/12/19 12:25:21 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -2211,6 +2211,7 @@ while (commands != NULL) uschar *to = commands->args[mailarg_index_to].u; int size = 0; int ptr = 0; + int badflag = 0; if (to == NULL) to = expand_string(US"$reply_address"); while (isspace(*to)) to++; @@ -2283,11 +2284,15 @@ while (commands != NULL) while (isspace(*tt)) tt++; } - if (log_addr == NULL) log_addr = string_sprintf("invalid-to-line"); - else log_addr[ptr] = 0; + if (log_addr == NULL) + { + log_addr = string_sprintf(">**bad-reply**"); + badflag = af_bad_reply; + } + else log_addr[ptr] = 0; addr = deliver_make_addr(log_addr, FALSE); - setflag(addr, af_pfr); + setflag(addr, (af_pfr|badflag)); if (commands->noerror) setflag(addr, af_ignore_error); addr->next = *generated; *generated = addr; diff --git a/src/src/structs.h b/src/src/structs.h index f95c63ac0..2fd1bde28 100644 --- a/src/src/structs.h +++ b/src/src/structs.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/structs.h,v 1.7 2005/09/12 15:09:55 ph10 Exp $ */ +/* $Cambridge: exim/src/src/structs.h,v 1.8 2005/12/19 12:25:21 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -503,6 +503,7 @@ typedef struct address_item_propagated { #define af_include_affixes 0x00800000 /* delivered with affixes in RCPT */ #define af_cert_verified 0x01000000 /* delivered with verified TLS cert */ #define af_pass_message 0x02000000 /* pass message in bounces */ +#define af_bad_reply 0x04000000 /* filter could not generate autoreply */ /* These flags must be propagated when a child is created */ -- 2.30.2