Merge branch 'debian'
[hcoop/debian/exim4.git] / debian / patches / 75_05-Fix-expansions-for-RFC-822-addresses-having-comments.patch
CommitLineData
01e60269
AM
1From f634b80846cc7ffcab65c9855bcb35312f0232e8 Mon Sep 17 00:00:00 2001
2From: Jasen Betts <jasen@xnet.co.nz>
3Date: Mon, 18 Feb 2019 13:52:16 +0000
4Subject: [PATCH 1/5] Fix expansions for RFC 822 addresses having comments in
5 local-part and/or domain. Bug 2375
6
7(cherry picked from commit e2ff8e24f41caca3623228b1ec66a3f3961ecad6)
8---
9 doc/ChangeLog | 3 +++
10 src/expand.c | 19 +++++++------------
11 test/scripts/0000-Basic/0002 | 7 +++++++
12 test/stdout/0002 | 7 +++++++
13 4 files changed, 24 insertions(+), 12 deletions(-)
14
15diff --git a/doc/ChangeLog b/doc/ChangeLog
16index 867a1d8a..9659da32 100644
17--- a/doc/ChangeLog
18+++ b/doc/ChangeLog
19@@ -16,10 +16,13 @@ JH/07 GnuTLS: Our use of late (post-handshake) certificate verification, under
20 to the client until the first read of encrypted data (typically the
21 response to EHLO). Add detection for that case and treat it as a failed
22 TLS connection attempt, so that the normal retry-in-clear can work (if
23 suitably configured).
24
25+JB/01 BZg 2375: fix expansions of 822 addresses having comments in local-part
26+ and/or domain. Found and fixed by Jason Betts.
27+
28
29 Exim version 4.92
30 -----------------
31
32 JH/01 Remove code calling the customisable local_scan function, unless a new
33diff --git a/src/expand.c b/src/expand.c
34index 2c290251..35ede718 100644
35--- a/src/expand.c
36+++ b/src/expand.c
37@@ -7071,20 +7071,15 @@ while (*s != 0)
38 uschar * error;
39 int start, end, domain;
40 uschar * t = parse_extract_address(sub, &error, &start, &end, &domain,
41 FALSE);
42 if (t)
43- if (c != EOP_DOMAIN)
44- {
45- if (c == EOP_LOCAL_PART && domain != 0) end = start + domain - 1;
46- yield = string_catn(yield, sub+start, end-start);
47- }
48- else if (domain != 0)
49- {
50- domain += start;
51- yield = string_catn(yield, sub+domain, end-domain);
52- }
53+ yield = c == EOP_DOMAIN
54+ ? string_cat(yield, t + domain)
55+ : c == EOP_LOCAL_PART && domain > 0
56+ ? string_catn(yield, t, domain - 1 )
57+ : string_cat(yield, t);
58 continue;
59 }
60
61 case EOP_ADDRESSES:
62 {
63@@ -7104,11 +7099,11 @@ while (*s != 0)
64 }
65 f.parse_allow_group = TRUE;
66
67 for (;;)
68 {
69- uschar *p = parse_find_address_end(sub, FALSE);
70+ uschar * p = parse_find_address_end(sub, FALSE);
71 uschar saveend = *p;
72 *p = '\0';
73 address = parse_extract_address(sub, &error, &start, &end, &domain,
74 FALSE);
75 *p = saveend;
76@@ -7117,11 +7112,11 @@ while (*s != 0)
77 done in chunks by searching for the separator character. At the
78 start, unless we are dealing with the first address of the output
79 list, add in a space if the new address begins with the separator
80 character, or is an empty string. */
81
82- if (address != NULL)
83+ if (address)
84 {
85 if (yield->ptr != save_ptr && address[0] == *outsep)
86 yield = string_catn(yield, US" ", 1);
87
88 for (;;)
89--
902.20.1
91