Fix cutthrough delivery for more than one iteration of address redirection. Bug...
authorJeremy Harris <jgh146exb@wizmail.org>
Sat, 11 Aug 2018 13:56:59 +0000 (14:56 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Sat, 11 Aug 2018 13:56:59 +0000 (14:56 +0100)
(cherry picked from commit d16931c81f3e500fa6eafe5ec1c5d8e7db63e65a
                and commit 8a6b4e02cd384193a5566e8601bdd97249b22284)

doc/doc-txt/ChangeLog
src/src/verify.c
test/confs/5400
test/confs/5408 [new symlink]
test/log/5408 [new file with mode: 0644]
test/scripts/5400-cutthrough/5408 [new file with mode: 0644]

index 018473e457f83701afaadf184083cce2eba3cb4e..3bd8c0a0d24a894be5c0d917644d2cc1777ef26f 100644 (file)
@@ -45,6 +45,11 @@ JH/18 Bug 2287: Fix the protocol name (eg utf8esmtp) for multiple messages
       using the SMTPUTF8 option on their MAIL FROM commands, in one connection.
       Previously the "utf8" would be re-prepended for every additional message.
 
       using the SMTPUTF8 option on their MAIL FROM commands, in one connection.
       Previously the "utf8" would be re-prepended for every additional message.
 
+JH/20 Bug 2296: Fix cutthrough for >1 address redirection.  Previously only
+      one parent address was copied, and bogus data was used at delivery-logging
+      time.  Either a crash (after delivery) or bogus log data could result.
+      Discovery and analysis by Tim Stewart.
+
 
 Exim version 4.91
 -----------------
 
 Exim version 4.91
 -----------------
index ffa6a14f9b9c70496d1548be78d691881c90eb51..3e7cf300802c6623c29acc4bc83d3dec212ba777 100644 (file)
@@ -1061,6 +1061,8 @@ no_conn:
        && !sx.lmtp
        )
       {
        && !sx.lmtp
        )
       {
+      address_item * parent, * caddr;
+
       HDEBUG(D_acl|D_v) debug_printf_indent("holding verify callout open for %s\n",
        cutthrough.delivery
        ? "cutthrough delivery" : "potential further verifies and delivery");
       HDEBUG(D_acl|D_v) debug_printf_indent("holding verify callout open for %s\n",
        cutthrough.delivery
        ? "cutthrough delivery" : "potential further verifies and delivery");
@@ -1082,12 +1084,16 @@ no_conn:
        cutthrough.host.address = string_copy(host->address);
        store_pool = oldpool;
        }
        cutthrough.host.address = string_copy(host->address);
        store_pool = oldpool;
        }
-      cutthrough.addr =                *addr;          /* Save the address_item for later logging */
+
+      /* Save the address_item and parent chain for later logging */
+      cutthrough.addr =                *addr;
       cutthrough.addr.next =   NULL;
       cutthrough.addr.host_used = &cutthrough.host;
       cutthrough.addr.next =   NULL;
       cutthrough.addr.host_used = &cutthrough.host;
-      if (addr->parent)
-        *(cutthrough.addr.parent = store_get(sizeof(address_item))) =
-         *addr->parent;
+      for (caddr = &cutthrough.addr, parent = addr->parent;
+          parent;
+          caddr = caddr->parent, parent = parent->parent)
+        *(caddr->parent = store_get(sizeof(address_item))) = *parent;
+
       ctblock.buffer = ctbuffer;
       ctblock.buffersize = sizeof(ctbuffer);
       ctblock.ptr = ctbuffer;
       ctblock.buffer = ctbuffer;
       ctblock.buffersize = sizeof(ctbuffer);
       ctblock.ptr = ctbuffer;
@@ -1919,6 +1925,9 @@ while (addr_new)
 #endif
           rc = do_callout(addr, host_list, &tf, callout, callout_overall,
             callout_connect, options, se_mailfrom, pm_mailfrom);
 #endif
           rc = do_callout(addr, host_list, &tf, callout, callout_overall,
             callout_connect, options, se_mailfrom, pm_mailfrom);
+#ifdef SUPPORT_TLS
+         deliver_set_expansions(NULL);
+#endif
           }
         }
       else
           }
         }
       else
index 5a5e60a8836abf90ece32b7a77b09af6e5bfd4a6..980e02a48222ada0bb425f683665938d85df3590 100644 (file)
@@ -10,7 +10,7 @@ OPT=
 
 primary_hostname = myhost.test.ex
 
 
 primary_hostname = myhost.test.ex
 
-log_selector = +received_recipients
+log_selector = +received_recipients +all_parents
 queue_only
 
 # ----- Main settings -----
 queue_only
 
 # ----- Main settings -----
@@ -34,6 +34,11 @@ ar:
 
 begin routers
 
 
 begin routers
 
+redir:
+  driver = redirect
+  local_parts = ^r
+  data =       ${substr_1:$local_part}@$domain
+
 dns:
   driver = dnslookup
   domains = localhost.test.ex : localhost4.test.ex : thishost.test.ex
 dns:
   driver = dnslookup
   domains = localhost.test.ex : localhost4.test.ex : thishost.test.ex
diff --git a/test/confs/5408 b/test/confs/5408
new file mode 120000 (symlink)
index 0000000..8f6811b
--- /dev/null
@@ -0,0 +1 @@
+5400
\ No newline at end of file
diff --git a/test/log/5408 b/test/log/5408
new file mode 100644 (file)
index 0000000..99fead1
--- /dev/null
@@ -0,0 +1,17 @@
+**NOTE: The delivery lines in this file have been sorted.
+1999-03-02 09:44:33 rcpt for userx@domain.com
+1999-03-02 09:44:33 10HmaX-0005vi-00 >> userx@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for userx@domain.com
+1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
+1999-03-02 09:44:33 rcpt for ruserx@domain.com
+1999-03-02 09:44:33 10HmaY-0005vi-00 >> userx@domain.com <ruserx@domain.com> R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for ruserx@domain.com
+1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
+1999-03-02 09:44:33 rcpt for rruserx@domain.com
+1999-03-02 09:44:33 10HmaZ-0005vi-00 >> userx@domain.com (ruserx@domain.com) <rruserx@domain.com> R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for rruserx@domain.com
+1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
+1999-03-02 09:44:33 rcpt for rrruserx@domain.com
+1999-03-02 09:44:33 10HmbA-0005vi-00 >> userx@domain.com (ruserx@domain.com, rruserx@domain.com) <rrruserx@domain.com> R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmbA-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for rrruserx@domain.com
+1999-03-02 09:44:33 10HmbA-0005vi-00 Completed
diff --git a/test/scripts/5400-cutthrough/5408 b/test/scripts/5400-cutthrough/5408
new file mode 100644 (file)
index 0000000..93f4d35
--- /dev/null
@@ -0,0 +1,115 @@
+# cutthrough_delivery with router redirections
+need_ipv4
+munge loopback
+#
+# Plain, no redirect
+server PORT_S
+220 ESMTP
+EHLO
+250 OK
+MAIL FROM:
+250 Sender OK
+RCPT TO:<userx@domain.com>
+250 Recipient OK
+DATA
+354 Send data
+.
+250 OK
+QUIT
+250 OK
+****
+exim -bs
+EHLO myhost.test.ex
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO:<userx@domain.com>
+DATA
+
+.
+QUIT
+****
+#
+#
+# One redirect
+server PORT_S
+220 ESMTP
+EHLO
+250 OK
+MAIL FROM:
+250 Sender OK
+RCPT TO:<userx@domain.com>
+250 Recipient OK
+DATA
+354 Send data
+.
+250 OK
+QUIT
+250 OK
+****
+exim -bs
+EHLO myhost.test.ex
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO:<ruserx@domain.com>
+DATA
+
+.
+QUIT
+****
+#
+#
+# Two redirects
+server PORT_S
+220 ESMTP
+EHLO
+250 OK
+MAIL FROM:
+250 Sender OK
+RCPT TO:<userx@domain.com>
+250 Recipient OK
+DATA
+354 Send data
+.
+250 OK
+QUIT
+250 OK
+****
+exim -bs
+EHLO myhost.test.ex
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO:<rruserx@domain.com>
+DATA
+
+.
+QUIT
+****
+#
+#
+# Three redirects
+server PORT_S
+220 ESMTP
+EHLO
+250 OK
+MAIL FROM:
+250 Sender OK
+RCPT TO:<userx@domain.com>
+250 Recipient OK
+DATA
+354 Send data
+.
+250 OK
+QUIT
+250 OK
+****
+exim -bs
+EHLO myhost.test.ex
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO:<rrruserx@domain.com>
+DATA
+
+.
+QUIT
+****
+#
+#
+sortlog
+no_stdout_check
+# End