Import Debian patch 4.84.2-2+deb8u3
[hcoop/debian/exim4.git] / debian / patches / 90_Cutthrough-Fix-bug-with-dot-only-line.patch
1 From 2d51a06458d4fb771dca34966cf2d19c6820ce61 Mon Sep 17 00:00:00 2001
2 From: Jeremy Harris <jgh146exb@wizmail.org>
3 Date: Thu, 21 Jan 2016 15:37:08 +0000
4 Subject: [PATCH] Cutthrough: Fix bug with dot-only line
5 JH/38 Fix cutthrough bug with body lines having a single dot. The dot was
6 incorrectly not doubled on cutthrough transmission, hence seen as a
7 body-termination at the receiving system - resulting in truncated mails.
8 Commonly the sender saw a TCP-level error, and retransmitted the nessage
9 via the normal store-and-forward channel. This could result in duplicates
10 received - but deduplicating mailstores were liable to retain only the
11 initial truncated version.
12 (cherry picked from commit 1bc460a64a0de0766d21f4f8660c6597bc410cbc)
13
14 --- exim4-4.84.2.orig/src/receive.c
15 +++ exim4-4.84.2/src/receive.c
16 @@ -838,7 +838,15 @@ while ((ch = (receive_getc)()) != EOF)
17 ch_state = 4;
18 continue;
19 }
20 - ch_state = 1; /* The dot itself is removed */
21 + /* The dot was removed at state 3. For a doubled dot, here, reinstate
22 + it to cutthrough. The current ch, dot or not, is passed both to cutthrough
23 + and to file below. */
24 + if (ch == '.')
25 + {
26 + uschar c= ch;
27 + (void) cutthrough_puts(&c, 1);
28 + }
29 + ch_state = 1;
30 break;
31
32 case 4: /* After [CR] LF . CR */