From 1bc460a64a0de0766d21f4f8660c6597bc410cbc Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 21 Jan 2016 15:37:08 +0000 Subject: [PATCH] Cutthrough: Fix bug with dot-only line --- doc/doc-txt/ChangeLog | 8 ++++++ src/src/receive.c | 10 ++++++- test/log/5400 | 4 +++ test/scripts/5400-cutthrough/5400 | 34 +++++++++++++++++++++++ test/stdout/5400 | 45 +++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 1 deletion(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index ad5c5a349..c4a2f00ce 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -156,6 +156,14 @@ JH/36 Bug 1778: longstanding bug in memory use by the ${run } expansion: A fresh JH/37 Bug 1769: Permit a VRFY ACL to override the default 252 response, and to use the domains and local_parts ACL conditions. +JH/38 Fix cutthrough bug with body lines having a single dot. The dot was + incorrectly not doubled on cutthrough transmission, hence seen as a + body-termination at the receiving system - resulting in truncated mails. + Commonly the sender saw a TCP-level error, and retransmitted the nessage + via the normal store-and-forward channel. This could result in duplicates + received - but deduplicating mailstores were liable to retain only the + initial truncated version. + Exim version 4.86 ----------------- diff --git a/src/src/receive.c b/src/src/receive.c index f2a94e0f8..a479e12cd 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -835,7 +835,15 @@ while ((ch = (receive_getc)()) != EOF) ch_state = 4; continue; } - ch_state = 1; /* The dot itself is removed */ + /* The dot was removed at state 3. For a doubled dot, here, reinstate + it to cutthrough. The current ch, dot or not, is passed both to cutthrough + and to file below. */ + if (ch == '.') + { + uschar c= ch; + (void) cutthrough_puts(&c, 1); + } + ch_state = 1; break; case 4: /* After [CR] LF . CR */ diff --git a/test/log/5400 b/test/log/5400 index a72dfeead..f8d7c9e8f 100644 --- a/test/log/5400 +++ b/test/log/5400 @@ -52,3 +52,7 @@ 1999-03-02 09:44:33 10HmbG-0005vi-00 >> userx@localhost4.test.ex R=dns T=smtp H=localhost4.test.ex [127.0.0.1] C="250 OK" 1999-03-02 09:44:33 10HmbG-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for userx@localhost4.test.ex usery@thishost.test.ex 1999-03-02 09:44:33 10HmbG-0005vi-00 Completed +1999-03-02 09:44:33 rcpt for userx@domain.com +1999-03-02 09:44:33 10HmbH-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 10HmbH-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for userx@domain.com +1999-03-02 09:44:33 10HmbH-0005vi-00 Completed diff --git a/test/scripts/5400-cutthrough/5400 b/test/scripts/5400-cutthrough/5400 index 5344ba51c..109b43928 100644 --- a/test/scripts/5400-cutthrough/5400 +++ b/test/scripts/5400-cutthrough/5400 @@ -414,5 +414,39 @@ QUIT # # # +# data having line with (logical, doubled on wire) single dot +server PORT_S +220 ESMTP +EHLO +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +DATA +354 Send data +. +250 OK +QUIT +250 OK +**** +exim -bs -odf +EHLO myhost.test.ex +MAIL FROM: +RCPT TO: +DATA +Subject: singledot test + +This data has a line with a single dot... next: +.. +and this is the line right after. +Next we have a line with a leading dot: +..test +and this is the next line. + +. +QUIT +**** +# # # End diff --git a/test/stdout/5400 b/test/stdout/5400 index 05f2ef037..20de2df09 100644 --- a/test/stdout/5400 +++ b/test/stdout/5400 @@ -115,6 +115,17 @@ 354 Enter message, ending with "." on a line by itself 250 OK id=10HmbG-0005vi-00 221 myhost.test.ex closing connection +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250-myhost.test.ex Hello CALLER at myhost.test.ex +250-SIZE 52428800 +250-8BITMIME +250-PIPELINING +250 HELP +250 OK +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmbH-0005vi-00 +221 myhost.test.ex closing connection ******** SERVER ******** Listening on port 1224 ... @@ -508,3 +519,37 @@ Date: Tue, 2 Mar 1999 09:44:33 +0000 QUIT 250 OK End of script +Listening on port 1224 ... +Connection request from [ip4.ip4.ip4.ip4] +220 ESMTP +EHLO myhost.test.ex +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +DATA +354 Send data +Received: from CALLER (helo=myhost.test.ex) + by myhost.test.ex with local-esmtp (Exim x.yz) + (envelope-from ) + id 10HmbH-0005vi-00 + for userx@domain.com; Tue, 2 Mar 1999 09:44:33 +0000 +Subject: singledot test +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 +X-hdr-rtr-new: +++ + +This data has a line with a single dot... next: +.. +and this is the line right after. +Next we have a line with a leading dot: +..test +and this is the next line. + +. +250 OK +QUIT +250 OK +End of script -- 2.25.1