View | Details | Raw Unified | Return to bug 274235 | Differences between
and this patch

Collapse All | Expand All

(-)b/mail/exim/Makefile (-20 / +3 lines)
Lines 1-6 Link Here
1
PORTNAME=	exim
1
PORTNAME=	exim
2
PORTVERSION?=	${EXIM_VERSION}
2
PORTVERSION?=	${EXIM_VERSION}
3
PORTREVISION?=	1
3
PORTREVISION?=	0
4
CATEGORIES=	mail
4
CATEGORIES=	mail
5
MASTER_SITES=	EXIM:exim
5
MASTER_SITES=	EXIM:exim
6
MASTER_SITE_SUBDIR=	/exim4/:exim \
6
MASTER_SITE_SUBDIR=	/exim4/:exim \
Lines 66-95 SQLITE_USES= pkgconfig sqlite Link Here
66
66
67
DEBIAN_PATCHES_PREFIX=	${FILESDIR}/debian/75
67
DEBIAN_PATCHES_PREFIX=	${FILESDIR}/debian/75
68
EXTRA_PATCHES= \
68
EXTRA_PATCHES= \
69
		${DEBIAN_PATCHES_PREFIX}_01-Fix-exit-on-attempt-to-rewrite-a-malformed-address.-.patch:-p1 \
70
		${DEBIAN_PATCHES_PREFIX}_05-SPF-fix-memory-accounting-for-error-case.patch:-p1 \
69
		${DEBIAN_PATCHES_PREFIX}_05-SPF-fix-memory-accounting-for-error-case.patch:-p1 \
71
		${DEBIAN_PATCHES_PREFIX}_08-Fix-regex-n-use-after-free.-Bug-2915.patch:-p1 \
72
		${DEBIAN_PATCHES_PREFIX}_09-Fix-non-WITH_CONTENT_SCAN-build.patch:-p1 \
73
		${DEBIAN_PATCHES_PREFIX}_10-Fix-non-WITH_CONTENT_SCAN-build-2.patch:-p1 \
74
		${DEBIAN_PATCHES_PREFIX}_11-Fix-non-WITH_CONTENT_SCAN-build-3.patch:-p1 \
70
		${DEBIAN_PATCHES_PREFIX}_11-Fix-non-WITH_CONTENT_SCAN-build-3.patch:-p1 \
75
		${DEBIAN_PATCHES_PREFIX}_16-GnuTLS-fix-for-clients-offering-no-TLS-extensions.patch:-p1 \
76
		${DEBIAN_PATCHES_PREFIX}_18-Fix-Build-with-libopendmarc-1.4.x-fixes-2728.patch:-p1 \
71
		${DEBIAN_PATCHES_PREFIX}_18-Fix-Build-with-libopendmarc-1.4.x-fixes-2728.patch:-p1 \
77
		${DEBIAN_PATCHES_PREFIX}_19-DMARC-fix-use-after-free-in-dmarc_dns_lookup.patch:-p1 \
78
		${DEBIAN_PATCHES_PREFIX}_22-Fix-daemon-startup.-Bug-2930.patch:-p1 \
79
		${DEBIAN_PATCHES_PREFIX}_23-Fix-reccipients-after-run.-.-Bug-2929.patch:-p1 \
80
		${DEBIAN_PATCHES_PREFIX}_31-Fix-regext-substring-capture-variables-for-null-matc.patch:-p1 \
81
		${DEBIAN_PATCHES_PREFIX}_32-Fix-regex-substring-capture-variables-for-null-match.patch:-p1 \
82
		${DEBIAN_PATCHES_PREFIX}_34-Fix-regex-substring-capture-commentary.-Bug-2933.patch:-p1 \
83
		${DEBIAN_PATCHES_PREFIX}_37-OpenSSL-when-preloading-creds-do-the-server-certs-be.patch:-p1 \
72
		${DEBIAN_PATCHES_PREFIX}_37-OpenSSL-when-preloading-creds-do-the-server-certs-be.patch:-p1 \
84
		${DEBIAN_PATCHES_PREFIX}_38-OpenSSL-fix-double-expansion-of-tls_verify_certifica.patch:-p1 \
73
		${DEBIAN_PATCHES_PREFIX}_38-OpenSSL-fix-double-expansion-of-tls_verify_certifica.patch:-p1 \
85
		${DEBIAN_PATCHES_PREFIX}_50-Fix-logging-of-max-size-log-line.patch:-p1 \
86
		${DEBIAN_PATCHES_PREFIX}_55-Fix-recursion-on-dns_again_means_nonexist.-Bug-2911.patch:-p1 \
87
		${DEBIAN_PATCHES_PREFIX}_58-Close-server-smtp-socket-explicitly-on-connect-ACL-d.patch:-p1 \
74
		${DEBIAN_PATCHES_PREFIX}_58-Close-server-smtp-socket-explicitly-on-connect-ACL-d.patch:-p1 \
88
		${DEBIAN_PATCHES_PREFIX}_60-OpenSSL-fix-tls_eccurve-setting-explicit-curve-group.patch:-p1 \
75
		${DEBIAN_PATCHES_PREFIX}_63-OpenSSL-log-conns-rejected-for-bad-ALPN-with-the-off.patch:-p1
89
		${DEBIAN_PATCHES_PREFIX}_62-OpenSSL-Fix-tls_eccurve-on-earlier-versions-than-3.0.patch:-p1 \
90
		${DEBIAN_PATCHES_PREFIX}_63-OpenSSL-log-conns-rejected-for-bad-ALPN-with-the-off.patch:-p1 \
91
		${DEBIAN_PATCHES_PREFIX}_64-DANE-do-not-check-dns_again_means_nonexist-for-TLSA-.patch:-p1 \
92
		${DEBIAN_PATCHES_PREFIX}_66-Fix-crash-in-expansions.patch:-p1
93
76
94
.include <bsd.port.options.mk>
77
.include <bsd.port.options.mk>
95
78
Lines 130-136 EXTRA_PATCHES+= ${FILESDIR}/extra-patch-Local-sa-exim.c Link Here
130
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-Local-sa-exim.conf
113
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-Local-sa-exim.conf
131
.endif
114
.endif
132
115
133
EXIM_VERSION=	4.96
116
EXIM_VERSION=	4.96.1
134
SA_EXIM_VERSION=4.2.1
117
SA_EXIM_VERSION=4.2.1
135
EXIM_INSTALL_ARG+=	"-no_chown" "-no_symlink"
118
EXIM_INSTALL_ARG+=	"-no_chown" "-no_symlink"
136
EXTRA_PATCHES+=	`${FIND} ${PATCHDIR} -name '74_*.patch'|${SORT} -h`
119
EXTRA_PATCHES+=	`${FIND} ${PATCHDIR} -name '74_*.patch'|${SORT} -h`
(-)b/mail/exim/distinfo (-3 / +3 lines)
Lines 1-5 Link Here
1
TIMESTAMP = 1681024359
1
TIMESTAMP = 1696250210
2
SHA256 (exim/exim-4.96.tar.bz2) = c7a413fec601cc44a8f5fe9e5b64cb24a7d133f3a4a976f33741d98ff0ec6b91
2
SHA256 (exim/exim-4.96.1.tar.bz2) = 26bbcd4f45483c7138912b4bd31022aee8abf8ac7cdff55839d7e2a9e4c60692
3
SIZE (exim/exim-4.96.tar.bz2) = 2047632
3
SIZE (exim/exim-4.96.1.tar.bz2) = 2048927
4
SHA256 (exim/sa-exim-4.2.1.tar.gz) = 24d4bf7b0fdddaea11f132981cebb6a86a4ab20ef54111a8ebd481b421c6e2c1
4
SHA256 (exim/sa-exim-4.2.1.tar.gz) = 24d4bf7b0fdddaea11f132981cebb6a86a4ab20ef54111a8ebd481b421c6e2c1
5
SIZE (exim/sa-exim-4.2.1.tar.gz) = 68933
5
SIZE (exim/sa-exim-4.2.1.tar.gz) = 68933
(-)a/mail/exim/files/debian/75_08-Fix-regex-n-use-after-free.-Bug-2915.patch (-193 lines)
Removed Link Here
1
From 4e9ed49f8f12eb331b29bd5b6dc3693c520fddc2 Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Wed, 31 Aug 2022 15:37:40 +0100
4
Subject: [PATCH] Fix $regex<n> use-after-free.  Bug 2915
5
6
---
7
 doc/ChangeLog           |  8 +++++++-
8
 src/exim.c                  |  4 +---
9
 src/expand.c                |  2 +-
10
 src/functions.h             |  1 +
11
 src/globals.c               |  2 +-
12
 src/regex.c                 | 29 ++++++++++++++++++-----------
13
 src/smtp_in.c               |  2 ++
14
 7 files changed, 55 insertions(+), 17 deletions(-)
15
16
--- a/doc/ChangeLog
17
+++ b/doc/ChangeLog
18
@@ -4,15 +4,21 @@
19
 
20
 JH/04 Bug 2903: avoid exit on an attempt to rewrite a malformed address.
21
       Make the rewrite never match and keep the logging.  Trust the
22
       admin to be using verify=header-syntax (to actually reject the message).
23
 
24
+JH/08 Bug 2915: Fix use-after-free for $regex<n> variables. Previously when
25
+      more than one message arrived in a single connection a reference from
26
+      the earlier message could be re-used.  Often a sigsegv resulted.
27
+      These variables were introduced in Exim 4.87.
28
+      Debug help from Graeme Fowler.
29
+
30
 
31
 Exim version 4.96
32
 -----------------
33
 
34
-JH/01 Move the wait-for-next-tick (needed for unique messmage IDs) from
35
+JH/01 Move the wait-for-next-tick (needed for unique message IDs) from
36
       after reception to before a subsequent reception.  This should
37
       mean slightly faster delivery, and also confirmation of reception
38
       to senders.
39
 
40
 JH/02 Move from using the pcre library to pcre2.  The former is no longer
41
--- a/src/exim.c
42
+++ b/src/exim.c
43
@@ -1999,12 +1999,10 @@
44
 
45
 regex_whitelisted_macro =
46
   regex_must_compile(US"^[A-Za-z0-9_/.-]*$", FALSE, TRUE);
47
 #endif
48
 
49
-for (i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
50
-
51
 /* If the program is called as "mailq" treat it as equivalent to "exim -bp";
52
 this seems to be a generally accepted convention, since one finds symbolic
53
 links called "mailq" in standard OS configurations. */
54
 
55
 if ((namelen == 5 && Ustrcmp(argv[0], "mailq") == 0) ||
56
@@ -6082,11 +6080,11 @@
57
   callout_address = NULL;
58
   sending_ip_address = NULL;
59
   deliver_localpart_data = deliver_domain_data =
60
   recipient_data = sender_data = NULL;
61
   acl_var_m = NULL;
62
-  for(int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
63
+  regex_vars_clear();
64
 
65
   store_reset(reset_point);
66
   }
67
 
68
 exim_exit(EXIT_SUCCESS);   /* Never returns */
69
--- a/src/expand.c
70
+++ b/src/expand.c
71
@@ -1871,11 +1871,11 @@
72
   {
73
   tree_node * node = tree_search(router_var, name + 2);
74
   return node ? node->data.ptr : strict_acl_vars ? NULL : US"";
75
   }
76
 
77
-/* Handle $auth<n> variables. */
78
+/* Handle $auth<n>, $regex<n> variables. */
79
 
80
 if (Ustrncmp(name, "auth", 4) == 0)
81
   {
82
   uschar *endptr;
83
   int n = Ustrtoul(name + 4, &endptr, 10);
84
--- a/src/functions.h
85
+++ b/src/functions.h
86
@@ -436,10 +436,11 @@
87
 extern int     regex(const uschar **);
88
 #endif
89
 extern BOOL    regex_match(const pcre2_code *, const uschar *, int, uschar **);
90
 extern BOOL    regex_match_and_setup(const pcre2_code *, const uschar *, int, int);
91
 extern const pcre2_code *regex_must_compile(const uschar *, BOOL, BOOL);
92
+extern void    regex_vars_clear(void);
93
 extern void    retry_add_item(address_item *, uschar *, int);
94
 extern BOOL    retry_check_address(const uschar *, host_item *, uschar *, BOOL,
95
                  uschar **, uschar **);
96
 extern retry_config *retry_find_config(const uschar *, const uschar *, int, int);
97
 extern BOOL    retry_ultimate_address_timeout(uschar *, const uschar *,
98
--- a/src/globals.c
99
+++ b/src/globals.c
100
@@ -1313,11 +1313,11 @@
101
 #ifndef DISABLE_PIPE_CONNECT
102
 const pcre2_code *regex_EARLY_PIPE   = NULL;
103
 #endif
104
 const pcre2_code *regex_ismsgid      = NULL;
105
 const pcre2_code *regex_smtp_code    = NULL;
106
-const uschar *regex_vars[REGEX_VARS];
107
+const uschar *regex_vars[REGEX_VARS] = { 0 };;
108
 #ifdef WHITELIST_D_MACROS
109
 const pcre2_code *regex_whitelisted_macro = NULL;
110
 #endif
111
 #ifdef WITH_CONTENT_SCAN
112
 uschar *regex_match_string     = NULL;
113
--- a/src/regex.c
114
+++ b/src/regex.c
115
@@ -94,22 +94,32 @@
116
   }
117
 pcre2_match_data_free(md);
118
 return FAIL;
119
 }
120
 
121
+
122
+/* reset expansion variables */
123
+void
124
+regex_vars_clear(void)
125
+{
126
+regex_match_string = NULL;
127
+for (int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
128
+}
129
+
130
+
131
+
132
 int
133
-regex(const uschar **listptr)
134
+regex(const uschar ** listptr)
135
 {
136
 unsigned long mbox_size;
137
-FILE *mbox_file;
138
-pcre_list *re_list_head;
139
-uschar *linebuffer;
140
+FILE * mbox_file;
141
+pcre_list * re_list_head;
142
+uschar * linebuffer;
143
 long f_pos = 0;
144
 int ret = FAIL;
145
 
146
-/* reset expansion variable */
147
-regex_match_string = NULL;
148
+regex_vars_clear();
149
 
150
 if (!mime_stream)				/* We are in the DATA ACL */
151
   {
152
   if (!(mbox_file = spool_mbox(&mbox_size, NULL, NULL)))
153
     {						/* error while spooling */
154
@@ -167,18 +177,17 @@
155
 
156
 
157
 int
158
 mime_regex(const uschar **listptr)
159
 {
160
-pcre_list *re_list_head = NULL;
161
-FILE *f;
162
-uschar *mime_subject = NULL;
163
+pcre_list * re_list_head = NULL;
164
+FILE * f;
165
+uschar * mime_subject = NULL;
166
 int mime_subject_len = 0;
167
 int ret;
168
 
169
-/* reset expansion variable */
170
-regex_match_string = NULL;
171
+regex_vars_clear();
172
 
173
 /* precompile our regexes */
174
 if (!(re_list_head = compile(*listptr)))
175
   return FAIL;			/* no regexes -> nothing to do */
176
 
177
--- a/src/smtp_in.c
178
+++ b/src/smtp_in.c
179
@@ -2155,12 +2155,14 @@
180
 prdr_requested = FALSE;
181
 #endif
182
 #ifdef SUPPORT_I18N
183
 message_smtputf8 = FALSE;
184
 #endif
185
+regex_vars_clear();
186
 body_linecount = body_zerocount = 0;
187
 
188
+lookup_value = NULL;				/* Can be set by ACL */
189
 sender_rate = sender_rate_limit = sender_rate_period = NULL;
190
 ratelimiters_mail = NULL;           /* Updated by ratelimit ACL condition */
191
                    /* Note that ratelimiters_conn persists across resets. */
192
 
193
 /* Reset message ACL variables */
(-)a/mail/exim/files/debian/75_09-Fix-non-WITH_CONTENT_SCAN-build.patch (-58 lines)
Removed Link Here
1
From d8ecc7bf97934a1e2244788c610c958cacd740bd Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Wed, 31 Aug 2022 17:03:37 +0100
4
Subject: [PATCH 1/3] Fix non-WITH_CONTENT_SCAN build.
5
6
Broken-by: 4e9ed49f8f
7
---
8
 src/exim.c  | 11 +++++++++++
9
 src/regex.c | 10 ----------
10
 2 files changed, 11 insertions(+), 10 deletions(-)
11
12
--- a/src/exim.c
13
+++ b/src/exim.c
14
@@ -1677,10 +1677,21 @@
15
   if ((s = expand_string(big_buffer))) printf("%s\n", CS s);
16
   else printf("Failed: %s\n", expand_string_message);
17
 }
18
 
19
 
20
+/* reset regex expansion variables */
21
+void
22
+regex_vars_clear(void)
23
+{
24
+regex_match_string = NULL;
25
+for (int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
26
+}
27
+
28
+
29
+
30
+
31
 
32
 /*************************************************
33
 *          Entry point and high-level code       *
34
 *************************************************/
35
 
36
--- a/src/regex.c
37
+++ b/src/regex.c
38
@@ -95,20 +95,10 @@
39
 pcre2_match_data_free(md);
40
 return FAIL;
41
 }
42
 
43
 
44
-/* reset expansion variables */
45
-void
46
-regex_vars_clear(void)
47
-{
48
-regex_match_string = NULL;
49
-for (int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
50
-}
51
-
52
-
53
-
54
 int
55
 regex(const uschar ** listptr)
56
 {
57
 unsigned long mbox_size;
58
 FILE * mbox_file;
(-)a/mail/exim/files/debian/75_10-Fix-non-WITH_CONTENT_SCAN-build-2.patch (-135 lines)
Removed Link Here
1
From 158dff9936e36a2d31d037d3988b9353458d6471 Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Wed, 31 Aug 2022 17:17:59 +0100
4
Subject: [PATCH 2/3] Fix non-WITH_CONTENT_SCAN build (2)
5
6
Broken-by: d8ecc7bf97
7
---
8
 src/exim.c      | 13 +------------
9
 src/functions.h |  2 +-
10
 src/globals.h   |  2 +-
11
 src/regex.c     | 10 ++++++++++
12
 src/smtp_in.c   |  2 ++
13
 5 files changed, 15 insertions(+), 14 deletions(-)
14
15
--- a/src/exim.c
16
+++ b/src/exim.c
17
@@ -1677,21 +1677,10 @@
18
   if ((s = expand_string(big_buffer))) printf("%s\n", CS s);
19
   else printf("Failed: %s\n", expand_string_message);
20
 }
21
 
22
 
23
-/* reset regex expansion variables */
24
-void
25
-regex_vars_clear(void)
26
-{
27
-regex_match_string = NULL;
28
-for (int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
29
-}
30
-
31
-
32
-
33
-
34
 
35
 /*************************************************
36
 *          Entry point and high-level code       *
37
 *************************************************/
38
 
39
@@ -6085,17 +6074,17 @@
40
   deliver_domain_orig = NULL;
41
   deliver_host = deliver_host_address = NULL;
42
   dnslist_domain = dnslist_matched = NULL;
43
 #ifdef WITH_CONTENT_SCAN
44
   malware_name = NULL;
45
+  regex_vars_clear();
46
 #endif
47
   callout_address = NULL;
48
   sending_ip_address = NULL;
49
   deliver_localpart_data = deliver_domain_data =
50
   recipient_data = sender_data = NULL;
51
   acl_var_m = NULL;
52
-  regex_vars_clear();
53
 
54
   store_reset(reset_point);
55
   }
56
 
57
 exim_exit(EXIT_SUCCESS);   /* Never returns */
58
--- a/src/functions.h
59
+++ b/src/functions.h
60
@@ -432,15 +432,15 @@
61
 extern BOOL    receive_msg(BOOL);
62
 extern int_eximarith_t receive_statvfs(BOOL, int *);
63
 extern void    receive_swallow_smtp(void);
64
 #ifdef WITH_CONTENT_SCAN
65
 extern int     regex(const uschar **);
66
+extern void    regex_vars_clear(void);
67
 #endif
68
 extern BOOL    regex_match(const pcre2_code *, const uschar *, int, uschar **);
69
 extern BOOL    regex_match_and_setup(const pcre2_code *, const uschar *, int, int);
70
 extern const pcre2_code *regex_must_compile(const uschar *, BOOL, BOOL);
71
-extern void    regex_vars_clear(void);
72
 extern void    retry_add_item(address_item *, uschar *, int);
73
 extern BOOL    retry_check_address(const uschar *, host_item *, uschar *, BOOL,
74
                  uschar **, uschar **);
75
 extern retry_config *retry_find_config(const uschar *, const uschar *, int, int);
76
 extern BOOL    retry_ultimate_address_timeout(uschar *, const uschar *,
77
--- a/src/globals.h
78
+++ b/src/globals.h
79
@@ -895,16 +895,16 @@
80
 #ifndef DISABLE_PIPE_CONNECT
81
 extern const pcre2_code  *regex_EARLY_PIPE;  /* For recognizing PIPE_CONNCT */
82
 #endif
83
 extern const pcre2_code  *regex_ismsgid;     /* Compiled r.e. for message ID */
84
 extern const pcre2_code  *regex_smtp_code;   /* For recognizing SMTP codes */
85
-extern const uschar *regex_vars[];           /* $regexN variables */
86
 #ifdef WHITELIST_D_MACROS
87
 extern const pcre2_code  *regex_whitelisted_macro; /* For -D macro values */
88
 #endif
89
 #ifdef WITH_CONTENT_SCAN
90
 extern uschar *regex_match_string;     /* regex that matched a line (regex ACL condition) */
91
+extern const uschar *regex_vars[];
92
 #endif
93
 extern int     remote_delivery_count;  /* Number of remote addresses */
94
 extern int     remote_max_parallel;    /* Maximum parallel delivery */
95
 extern uschar *remote_sort_domains;    /* Remote domain sorting order */
96
 extern retry_config *retries;          /* Chain of retry config information */
97
--- a/src/regex.c
98
+++ b/src/regex.c
99
@@ -95,10 +95,20 @@
100
 pcre2_match_data_free(md);
101
 return FAIL;
102
 }
103
 
104
 
105
+/* reset expansion variables */
106
+void
107
+regex_vars_clear(void)
108
+{
109
+regex_match_string = NULL;
110
+for (int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
111
+}
112
+
113
+
114
+
115
 int
116
 regex(const uschar ** listptr)
117
 {
118
 unsigned long mbox_size;
119
 FILE * mbox_file;
120
--- a/src/smtp_in.c
121
+++ b/src/smtp_in.c
122
@@ -2155,11 +2155,13 @@
123
 prdr_requested = FALSE;
124
 #endif
125
 #ifdef SUPPORT_I18N
126
 message_smtputf8 = FALSE;
127
 #endif
128
+#ifdef WITH_CONTENT_SCAN
129
 regex_vars_clear();
130
+#endif
131
 body_linecount = body_zerocount = 0;
132
 
133
 lookup_value = NULL;				/* Can be set by ACL */
134
 sender_rate = sender_rate_limit = sender_rate_period = NULL;
135
 ratelimiters_mail = NULL;           /* Updated by ratelimit ACL condition */
(-)a/mail/exim/files/debian/75_16-GnuTLS-fix-for-clients-offering-no-TLS-extensions.patch (-114 lines)
Removed Link Here
1
From ece23f05d6a430a461a75639197271c23f6858ec Mon Sep 17 00:00:00 2001
2
From: Jasen Betts <jasen@xnet.co.nz>
3
Date: Fri, 30 Sep 2022 13:49:41 +0100
4
Subject: [PATCH] GnuTLS: fix for clients offering no TLS extensions
5
6
---
7
 doc/ChangeLog              |  3 +++
8
 src/tls-gnu.c                  |  3 ++-
9
 src/tls-openssl.c              | 39 +++++++++++++++---------------
10
 test/confs/2091                    |  1 +
11
 test/log/2091                      |  3 +++
12
 test/scripts/2090-GnuTLS-ALPN/2091 | 19 +++++++++++++++
13
 test/stdout/2091                   | 21 ++++++++++++++++
14
 7 files changed, 68 insertions(+), 21 deletions(-)
15
 create mode 120000 test/confs/2091
16
 create mode 100644 test/log/2091
17
 create mode 100644 test/scripts/2090-GnuTLS-ALPN/2091
18
 create mode 100644 test/stdout/2091
19
20
--- a/doc/ChangeLog
21
+++ b/doc/ChangeLog
22
@@ -10,10 +10,14 @@
23
       more than one message arrived in a single connection a reference from
24
       the earlier message could be re-used.  Often a sigsegv resulted.
25
       These variables were introduced in Exim 4.87.
26
       Debug help from Graeme Fowler.
27
 
28
+JH/10 GnuTLS: fix for (IOT?) clients offering no TLS extensions at all.
29
+      Find and fix by Jasen Betts.
30
+
31
+
32
 
33
 Exim version 4.96
34
 -----------------
35
 
36
 JH/01 Move the wait-for-next-tick (needed for unique message IDs) from
37
--- a/src/tls-gnu.c
38
+++ b/src/tls-gnu.c
39
@@ -1130,12 +1130,13 @@
40
 static int
41
 tls_server_clienthello_cb(gnutls_session_t session, unsigned int htype,
42
   unsigned when, unsigned int incoming, const gnutls_datum_t * msg)
43
 {
44
 /* Call fn for each extension seen.  3.6.3 onwards */
45
-return gnutls_ext_raw_parse(NULL, tls_server_clienthello_ext, msg,
46
+int rc = gnutls_ext_raw_parse(NULL, tls_server_clienthello_ext, msg,
47
 			   GNUTLS_EXT_RAW_FLAG_TLS_CLIENT_HELLO);
48
+return rc == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE ? 0 : rc;
49
 }
50
 
51
 
52
 # ifdef notdef_crashes
53
 /* Make a note that we saw a status-response */
54
--- a/src/tls-openssl.c
55
+++ b/src/tls-openssl.c
56
@@ -940,40 +940,39 @@
57
 
58
 Returns:    nothing
59
 */
60
 
61
 static void
62
-info_callback(SSL *s, int where, int ret)
63
+info_callback(SSL * s, int where, int ret)
64
 {
65
 DEBUG(D_tls)
66
   {
67
-  const uschar * str;
68
+  gstring * g = NULL;
69
 
70
-  if (where & SSL_ST_CONNECT)
71
-     str = US"SSL_connect";
72
-  else if (where & SSL_ST_ACCEPT)
73
-     str = US"SSL_accept";
74
-  else
75
-     str = US"SSL info (undefined)";
76
+  if (where & SSL_ST_CONNECT) g = string_append_listele(g, ',', US"SSL_connect");
77
+  if (where & SSL_ST_ACCEPT)  g = string_append_listele(g, ',', US"SSL_accept");
78
+  if (where & SSL_CB_LOOP)    g = string_append_listele(g, ',', US"state_chg");
79
+  if (where & SSL_CB_EXIT)    g = string_append_listele(g, ',', US"hshake_exit");
80
+  if (where & SSL_CB_READ)    g = string_append_listele(g, ',', US"read");
81
+  if (where & SSL_CB_WRITE)   g = string_append_listele(g, ',', US"write");
82
+  if (where & SSL_CB_ALERT)   g = string_append_listele(g, ',', US"alert");
83
+  if (where & SSL_CB_HANDSHAKE_START) g = string_append_listele(g, ',', US"hshake_start");
84
+  if (where & SSL_CB_HANDSHAKE_DONE)  g = string_append_listele(g, ',', US"hshake_done");
85
 
86
   if (where & SSL_CB_LOOP)
87
-     debug_printf("%s: %s\n", str, SSL_state_string_long(s));
88
+     debug_printf("SSL %s: %s\n", g->s, SSL_state_string_long(s));
89
   else if (where & SSL_CB_ALERT)
90
-    debug_printf("SSL3 alert %s:%s:%s\n",
91
-	  str = where & SSL_CB_READ ? US"read" : US"write",
92
+    debug_printf("SSL %s %s:%s\n", g->s,
93
 	  SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret));
94
   else if (where & SSL_CB_EXIT)
95
     {
96
-    if (ret == 0)
97
-      debug_printf("%s: failed in %s\n", str, SSL_state_string_long(s));
98
-    else if (ret < 0)
99
-      debug_printf("%s: error in %s\n", str, SSL_state_string_long(s));
100
+    if (ret <= 0)
101
+      debug_printf("SSL %s: %s in %s\n", g->s,
102
+	ret == 0 ? "failed" : "error", SSL_state_string_long(s));
103
     }
104
-  else if (where & SSL_CB_HANDSHAKE_START)
105
-     debug_printf("%s: hshake start: %s\n", str, SSL_state_string_long(s));
106
-  else if (where & SSL_CB_HANDSHAKE_DONE)
107
-     debug_printf("%s: hshake done: %s\n", str, SSL_state_string_long(s));
108
+  else if (where & (SSL_CB_HANDSHAKE_START | SSL_CB_HANDSHAKE_DONE))
109
+     debug_printf("SSL %s: %s\n", g->s, SSL_state_string_long(s));
110
   }
111
 }
112
 
113
 #ifdef OPENSSL_HAVE_KEYLOG_CB
114
 static void
(-)b/mail/exim/files/debian/75_18-Fix-Build-with-libopendmarc-1.4.x-fixes-2728.patch (-17 lines)
Lines 4-31 Date: Sat, 15 Oct 2022 19:30:58 +0200 Link Here
4
Subject: [PATCH 1/2] Fix: Build with libopendmarc 1.4.x (fixes 2728)
4
Subject: [PATCH 1/2] Fix: Build with libopendmarc 1.4.x (fixes 2728)
5
5
6
---
6
---
7
 doc/ChangeLog     | 3 +++
8
 src/EDITME            | 7 +++++--
7
 src/EDITME            | 7 +++++--
9
 src/config.h.defaults | 1 +
8
 src/config.h.defaults | 1 +
10
 src/dmarc.c           | 7 ++++++-
9
 src/dmarc.c           | 7 ++++++-
11
 4 files changed, 15 insertions(+), 3 deletions(-)
10
 4 files changed, 15 insertions(+), 3 deletions(-)
12
11
13
--- a/doc/ChangeLog
14
+++ b/doc/ChangeLog
15
@@ -13,10 +13,13 @@
16
       Debug help from Graeme Fowler.
17
 
18
 JH/10 GnuTLS: fix for (IOT?) clients offering no TLS extensions at all.
19
       Find and fix by Jasen Betts.
20
 
21
+HS/01 Bug 2728: Introduce EDITME option "DMARC_API" to work around incompatible
22
+      API changes in libopendmarc.
23
+
24
 
25
 
26
 Exim version 4.96
27
 -----------------
28
 
29
--- a/src/EDITME
12
--- a/src/EDITME
30
+++ b/src/EDITME
13
+++ b/src/EDITME
31
@@ -600,18 +600,21 @@
14
@@ -600,18 +600,21 @@
(-)a/mail/exim/files/debian/75_19-DMARC-fix-use-after-free-in-dmarc_dns_lookup.patch (-39 lines)
Removed Link Here
1
From 12fb3842f81bcbd4a4519d5728f2d7e0e3ca1445 Mon Sep 17 00:00:00 2001
2
From: Lorenz Brun <lorenz@brun.one>
3
Date: Fri, 14 Oct 2022 21:02:51 +0200
4
Subject: [PATCH 2/2] DMARC: fix use-after-free in dmarc_dns_lookup
5
6
This fixes a use-after-free in dmarc_dns_lookup where the result
7
of dns_lookup in dnsa is freed before the required data is copied out.
8
9
Fixes: 9258363 ("DNS: explicit alloc/free of workspace")
10
---
11
 src/dmarc.c | 3 ++-
12
 1 file changed, 2 insertions(+), 1 deletion(-)
13
14
diff --git a/src/dmarc.c b/src/dmarc.c
15
index ad0c26c91..53c2752ac 100644
16
--- a/src/dmarc.c
17
+++ b/src/dmarc.c
18
@@ -226,16 +226,17 @@ dns_scan dnss;
19
 int rc = dns_lookup(dnsa, string_sprintf("_dmarc.%s", dom), T_TXT, NULL);
20
 
21
 if (rc == DNS_SUCCEED)
22
   for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_ANSWERS); rr;
23
        rr = dns_next_rr(dnsa, &dnss, RESET_NEXT))
24
     if (rr->type == T_TXT && rr->size > 3)
25
       {
26
+      uschar *record = string_copyn_taint(US rr->data, rr->size, GET_TAINTED);
27
       store_free_dns_answer(dnsa);
28
-      return string_copyn_taint(US rr->data, rr->size, GET_TAINTED);
29
+      return record;
30
       }
31
 store_free_dns_answer(dnsa);
32
 return NULL;
33
 }
34
 
35
 
36
 static int
37
-- 
38
2.35.1
39
(-)a/mail/exim/files/debian/75_22-Fix-daemon-startup.-Bug-2930.patch (-68 lines)
Removed Link Here
1
From 221321d2c51b83d1feced80ecd6c2fe33ec5456c Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Thu, 3 Nov 2022 20:08:25 +0000
4
Subject: [PATCH 1/2] Fix daemon startup.  Bug 2930
5
6
Broken-by: 7d5055276a
7
---
8
 doc/ChangeLog | 4 ++++
9
 src/daemon.c      | 8 ++++++--
10
 2 files changed, 10 insertions(+), 2 deletions(-)
11
12
--- a/doc/ChangeLog
13
+++ b/doc/ChangeLog
14
@@ -16,10 +16,14 @@
15
       Find and fix by Jasen Betts.
16
 
17
 HS/01 Bug 2728: Introduce EDITME option "DMARC_API" to work around incompatible
18
       API changes in libopendmarc.
19
 
20
+JH/12 Bug 2930: Fix daemon startup.  When started from any process apart from
21
+      pid 1, in the normal "background daemon" mode, having to drop process-
22
+      group leadership also lost track of needing to create listener sockets.
23
+
24
 
25
 
26
 Exim version 4.96
27
 -----------------
28
 
29
--- a/src/daemon.c
30
+++ b/src/daemon.c
31
@@ -1744,19 +1744,23 @@
32
   {
33
   /* If the parent process of this one has pid == 1, we are re-initializing the
34
   daemon as the result of a SIGHUP. In this case, there is no need to do
35
   anything, because the controlling terminal has long gone. Otherwise, fork, in
36
   case current process is a process group leader (see 'man setsid' for an
37
-  explanation) before calling setsid(). */
38
+  explanation) before calling setsid().
39
+  All other forks want daemon_listen cleared. Rather than blow a register, jsut
40
+  restore it here. */
41
 
42
   if (getppid() != 1)
43
     {
44
+    BOOL daemon_listen = f.daemon_listen;
45
     pid_t pid = exim_fork(US"daemon");
46
     if (pid < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE,
47
       "fork() failed when starting daemon: %s", strerror(errno));
48
     if (pid > 0) exit(EXIT_SUCCESS);      /* in parent process, just exit */
49
     (void)setsid();                       /* release controlling terminal */
50
+    f.daemon_listen = daemon_listen;
51
     }
52
   }
53
 
54
 /* We are now in the disconnected, daemon process (unless debugging). Set up
55
 the listening sockets if required. */
56
@@ -2090,11 +2094,11 @@
57
 	      {				/* found; append port to list */
58
 	      for (p = i2->log; *p; ) p++;	/* end of existing string */
59
 	      if (*--p == '}') *p = '\0';	/* drop EOL */
60
 	      while (isdigit(*--p)) ;		/* char before port */
61
 
62
-	      i2->log = *p == ':'		/* no list yet? */
63
+	      i2->log = *p == ':'		/* no list yet?     { */
64
 		? string_sprintf("%.*s{%s,%d}",
65
 		  (int)(p - i2->log + 1), i2->log, p+1, ipa->port)
66
 		: string_sprintf("%s,%d}", i2->log, ipa->port);
67
 	      ipa->log = NULL;
68
 	      break;
(-)a/mail/exim/files/debian/75_23-Fix-reccipients-after-run.-.-Bug-2929.patch (-45 lines)
Removed Link Here
1
From 6b331d5834d12bdda21857cd6fffac17038ce3c7 Mon Sep 17 00:00:00 2001
2
From: Ruben Jenster <r.jenster@drachenfels.de>
3
Date: Thu, 3 Nov 2022 21:38:15 +0000
4
Subject: [PATCH 2/2] Fix $reccipients after ${run...}.  Bug 2929
5
6
Broken-by: cfe6acff2d
7
---
8
 doc/ChangeLog | 3 +++
9
 src/transport.c   | 3 ++-
10
 2 files changed, 5 insertions(+), 1 deletion(-)
11
12
--- a/doc/ChangeLog
13
+++ b/doc/ChangeLog
14
@@ -20,10 +20,13 @@
15
 
16
 JH/12 Bug 2930: Fix daemon startup.  When started from any process apart from
17
       pid 1, in the normal "background daemon" mode, having to drop process-
18
       group leadership also lost track of needing to create listener sockets.
19
 
20
+JH/13 Bug 2929: Fix using $recipients after ${run...}.  A change made for 4.96
21
+      resulted in the variable appearing empty.  Find and fix by Ruben Jenster.
22
+
23
 
24
 
25
 Exim version 4.96
26
 -----------------
27
 
28
--- a/src/transport.c
29
+++ b/src/transport.c
30
@@ -2342,13 +2342,14 @@
31
     /* Handle normal expansion string */
32
 
33
     else
34
       {
35
       const uschar *expanded_arg;
36
+      BOOL enable_dollar_recipients_g = f.enable_dollar_recipients;
37
       f.enable_dollar_recipients = allow_dollar_recipients;
38
       expanded_arg = expand_cstring(argv[i]);
39
-      f.enable_dollar_recipients = FALSE;
40
+      f.enable_dollar_recipients = enable_dollar_recipients_g;
41
 
42
       if (!expanded_arg)
43
         {
44
         uschar *msg = string_sprintf("Expansion of \"%s\" "
45
           "from command \"%s\" in %s failed: %s",
(-)a/mail/exim/files/debian/75_31-Fix-regext-substring-capture-variables-for-null-matc.patch (-79 lines)
Removed Link Here
1
From e63825824cc406c160ccbf2b154c5d81b168604a Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Fri, 11 Nov 2022 00:05:59 +0000
4
Subject: [PATCH 1/2] Fix regext substring capture variables for null matches. 
5
 Bug 2933
6
7
broken-by: 59d66fdc13f0
8
---
9
 doc/ChangeLog | 5 +++++
10
 src/exim.c        | 2 ++
11
 src/malware.c     | 3 +++
12
 src/regex.c       | 2 +-
13
 4 files changed, 11 insertions(+), 1 deletion(-)
14
15
--- a/doc/ChangeLog
16
+++ b/doc/ChangeLog
17
@@ -22,10 +22,15 @@
18
       pid 1, in the normal "background daemon" mode, having to drop process-
19
       group leadership also lost track of needing to create listener sockets.
20
 
21
 JH/13 Bug 2929: Fix using $recipients after ${run...}.  A change made for 4.96
22
       resulted in the variable appearing empty.  Find and fix by Ruben Jenster.
23
+ 
24
+JH/14 Bug 2933: Fix regex substring match variables for null matches. Since 4.96
25
+      a capture group which obtained no text (eg. "(abc)*" matching zero
26
+      occurrences) could cause a segfault if the corresponding $<n> was
27
+      expanded.
28
 
29
 
30
 
31
 Exim version 4.96
32
 -----------------
33
--- a/src/exim.c
34
+++ b/src/exim.c
35
@@ -167,10 +167,12 @@
36
   for (int matchnum = setup < 0 ? 0 : 1; matchnum < res; matchnum++)
37
     {
38
     PCRE2_SIZE len;
39
     pcre2_substring_get_bynumber(md, matchnum,
40
       (PCRE2_UCHAR **)&expand_nstring[expand_nmax], &len);
41
+    if (!expand_nstring[expand_nmax])
42
+      { expand_nstring[expand_nmax] = US""; len = 0; }
43
     expand_nlength[expand_nmax++] = (int)len;
44
     }
45
   expand_nmax--;
46
   }
47
 else if (res != PCRE2_ERROR_NOMATCH) DEBUG(D_any)
48
--- a/src/malware.c
49
+++ b/src/malware.c
50
@@ -323,11 +323,14 @@
51
 int i = pcre2_match(cre, text, PCRE2_ZERO_TERMINATED, 0, 0, md, pcre_mtc_ctx);
52
 PCRE2_UCHAR * substr = NULL;
53
 PCRE2_SIZE slen;
54
 
55
 if (i >= 2)				/* Got it */
56
+  {
57
   pcre2_substring_get_bynumber(md, 1, &substr, &slen);
58
+  if (!substr) substr = US"";
59
+  }
60
 return US substr;
61
 }
62
 
63
 static const pcre2_code *
64
 m_pcre_nextinlist(const uschar ** list, int * sep,
65
--- a/src/regex.c
66
+++ b/src/regex.c
67
@@ -84,11 +84,11 @@
68
     for (int nn = 1; nn < n; nn++)
69
       {
70
       PCRE2_UCHAR * cstr;
71
       PCRE2_SIZE cslen;
72
       pcre2_substring_get_bynumber(md, nn, &cstr, &cslen);
73
-      regex_vars[nn-1] = CUS cstr;
74
+      regex_vars[nn-1] = cstr ? CUS cstr : CUS"";
75
       }
76
 
77
     return OK;
78
     }
79
   }
(-)a/mail/exim/files/debian/75_32-Fix-regex-substring-capture-variables-for-null-match.patch (-94 lines)
Removed Link Here
1
From 7ad1a2b2cc57b5f4bcb59186a9a8abcbed9f4f76 Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Fri, 11 Nov 2022 18:22:00 +0000
4
Subject: [PATCH 2/2] Fix regex substring capture variables for null matches
5
 (again).  Bug 2933
6
7
Broken-by: 59d66fdc13f0
8
---
9
 src/exim.c               | 11 +++++------
10
 src/malware.c            | 10 +++++-----
11
 src/regex.c              |  8 ++++----
12
 test/aux-var-src/0383.F      |  4 ++--
13
 test/log/0383                |  4 ++--
14
 test/mail/0383.CALLER        |  8 ++++----
15
 test/scripts/0000-Basic/0002 |  2 ++
16
 test/stdout/0002             |  2 ++
17
 8 files changed, 26 insertions(+), 23 deletions(-)
18
19
--- a/src/exim.c
20
+++ b/src/exim.c
21
@@ -160,20 +160,19 @@
22
 			PCRE_EOPT | options, md, pcre_mtc_ctx);
23
 BOOL yield;
24
 
25
 if ((yield = (res >= 0)))
26
   {
27
+  PCRE2_SIZE * ovec = pcre2_get_ovector_pointer(md);
28
   res = pcre2_get_ovector_count(md);
29
   expand_nmax = setup < 0 ? 0 : setup + 1;
30
   for (int matchnum = setup < 0 ? 0 : 1; matchnum < res; matchnum++)
31
     {
32
-    PCRE2_SIZE len;
33
-    pcre2_substring_get_bynumber(md, matchnum,
34
-      (PCRE2_UCHAR **)&expand_nstring[expand_nmax], &len);
35
-    if (!expand_nstring[expand_nmax])
36
-      { expand_nstring[expand_nmax] = US""; len = 0; }
37
-    expand_nlength[expand_nmax++] = (int)len;
38
+    int off = matchnum * 2;
39
+    int len = ovec[off + 1] - ovec[off];
40
+    expand_nstring[expand_nmax] = string_copyn(subject + ovec[off], len);
41
+    expand_nlength[expand_nmax++] = len;
42
     }
43
   expand_nmax--;
44
   }
45
 else if (res != PCRE2_ERROR_NOMATCH) DEBUG(D_any)
46
   {
47
--- a/src/malware.c
48
+++ b/src/malware.c
49
@@ -319,19 +319,19 @@
50
 uschar *
51
 m_pcre_exec(const pcre2_code * cre, uschar * text)
52
 {
53
 pcre2_match_data * md = pcre2_match_data_create(2, pcre_gen_ctx);
54
 int i = pcre2_match(cre, text, PCRE2_ZERO_TERMINATED, 0, 0, md, pcre_mtc_ctx);
55
-PCRE2_UCHAR * substr = NULL;
56
-PCRE2_SIZE slen;
57
+uschar * substr = NULL;
58
 
59
 if (i >= 2)				/* Got it */
60
   {
61
-  pcre2_substring_get_bynumber(md, 1, &substr, &slen);
62
-  if (!substr) substr = US"";
63
+  PCRE2_SIZE * ovec = pcre2_get_ovector_pointer(md);
64
+  int len = ovec[3] - ovec[2];
65
+  substr = string_copyn(text + ovec[2], len);
66
   }
67
-return US substr;
68
+return substr;
69
 }
70
 
71
 static const pcre2_code *
72
 m_pcre_nextinlist(const uschar ** list, int * sep,
73
  char * listerr, uschar ** errstr)
74
--- a/src/regex.c
75
+++ b/src/regex.c
76
@@ -81,14 +81,14 @@
77
 	      sizeof(regex_match_string_buffer)-1);
78
     regex_match_string = regex_match_string_buffer;
79
 
80
     for (int nn = 1; nn < n; nn++)
81
       {
82
-      PCRE2_UCHAR * cstr;
83
-      PCRE2_SIZE cslen;
84
-      pcre2_substring_get_bynumber(md, nn, &cstr, &cslen);
85
-      regex_vars[nn-1] = cstr ? CUS cstr : CUS"";
86
+      PCRE2_SIZE * ovec = pcre2_get_ovector_pointer(md);
87
+      int off = nn * 2;
88
+      int len = ovec[off + 1] - ovec[off];
89
+      regex_vars[nn-1] = string_copyn(linebuffer + ovec[off], len);
90
       }
91
 
92
     return OK;
93
     }
94
   }
(-)a/mail/exim/files/debian/75_34-Fix-regex-substring-capture-commentary.-Bug-2933.patch (-48 lines)
Removed Link Here
1
From 9ba47886c71d40edc99b026a99edee269d9c9c6f Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Sat, 12 Nov 2022 12:38:22 +0000
4
Subject: [PATCH] Fix regex substring capture - commentary.  Bug 2933
5
6
Broken-by (corrected): 22ed7a5295f1
7
---
8
 src/exim.c | 9 ++++++++-
9
 1 file changed, 8 insertions(+), 1 deletion(-)
10
11
diff --git a/src/exim.c b/src/exim.c
12
index 16c0184e0..625494ce4 100644
13
--- a/src/exim.c
14
+++ b/src/exim.c
15
@@ -102,11 +102,13 @@ pcre_gen_mtc_ctx = pcre2_match_context_create(pcre_gen_ctx);
16
 *   Execute regular expression and set strings   *
17
 *************************************************/
18
 
19
 /* This function runs a regular expression match, and sets up the pointers to
20
 the matched substrings.  The matched strings are copied so the lifetime of
21
-the subject is not a problem.
22
+the subject is not a problem.  Matched strings will have the same taint status
23
+as the subject string (this is not a de-taint method, and must not be made so
24
+given the support for wildcards in REs).
25
 
26
 Arguments:
27
   re          the compiled expression
28
   subject     the subject string
29
   options     additional PCRE options
30
@@ -130,10 +132,15 @@ if ((yield = (res >= 0)))
31
   PCRE2_SIZE * ovec = pcre2_get_ovector_pointer(md);
32
   res = pcre2_get_ovector_count(md);
33
   expand_nmax = setup < 0 ? 0 : setup + 1;
34
   for (int matchnum = setup < 0 ? 0 : 1; matchnum < res; matchnum++)
35
     {
36
+    /* Although PCRE2 has a pcre2_substring_get_bynumber() conveneience, it
37
+    seems to return a bad pointer when a capture group had no data, eg. (.*)
38
+    matching zero letters.  So use the underlying ovec and hope (!) that the
39
+    offsets are sane (including that case).  Should we go further and range-
40
+    check each one vs. the subject string length? */
41
     int off = matchnum * 2;
42
     int len = ovec[off + 1] - ovec[off];
43
     expand_nstring[expand_nmax] = string_copyn(subject + ovec[off], len);
44
     expand_nlength[expand_nmax++] = len;
45
     }
46
-- 
47
2.35.1
48
(-)a/mail/exim/files/debian/75_50-Fix-logging-of-max-size-log-line.patch (-82 lines)
Removed Link Here
1
From 1ed24e36e279c922d3366f6c3144570cc5f54d7a Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Mon, 19 Dec 2022 21:09:17 +0000
4
Subject: [PATCH] Fix logging of max-size log line
5
6
Broken-by: d12746bc15d8
7
---
8
 doc/ChangeLog        |  5 +++++
9
 src/log.c                |  7 ++++---
10
 test/confs/0633              | 21 ++++++++++++++++++++
11
 test/scripts/0000-Basic/0633 |  9 +++++++++
12
 test/stderr/0633             | 38 ++++++++++++++++++++++++++++++++++++
13
 test/stdout/0633             | 15 ++++++++++++++
14
 6 files changed, 92 insertions(+), 3 deletions(-)
15
 create mode 100644 test/confs/0633
16
 create mode 100644 test/scripts/0000-Basic/0633
17
 create mode 100644 test/stderr/0633
18
 create mode 100644 test/stdout/0633
19
20
--- a/doc/ChangeLog
21
+++ b/doc/ChangeLog
22
@@ -28,10 +28,15 @@ JH/13 Bug 2929: Fix using $recipients af
23
 JH/14 Bug 2933: Fix regex substring match variables for null matches. Since 4.96
24
       a capture group which obtained no text (eg. "(abc)*" matching zero
25
       occurrences) could cause a segfault if the corresponding $<n> was
26
       expanded.
27
 
28
+JH/18 Fix a fencepost error in logging.  Previously (since 4.92) when a log line
29
+      was exactly sized compared to the log buffer, a crash occurred with the
30
+      misleading message "bad memory reference; pool not found".
31
+      Found and traced by Jasen Betts.
32
+
33
 
34
 
35
 Exim version 4.96
36
 -----------------
37
 
38
--- a/src/log.c
39
+++ b/src/log.c
40
@@ -803,11 +803,11 @@ Returns:    nothing
41
 void
42
 log_write(unsigned int selector, int flags, const char *format, ...)
43
 {
44
 int paniclogfd;
45
 ssize_t written_len;
46
-gstring gs = { .size = LOG_BUFFER_SIZE-1, .ptr = 0, .s = log_buffer };
47
+gstring gs = { .size = LOG_BUFFER_SIZE-2, .ptr = 0, .s = log_buffer };
48
 gstring * g;
49
 va_list ap;
50
 
51
 /* If panic_recurseflag is set, we have failed to open the panic log. This is
52
 the ultimate disaster. First try to write the message to a debug file and/or
53
@@ -949,15 +949,14 @@ DEBUG(D_any|D_v)
54
     g->ptr = i;
55
     g = string_cat(g, US"**** log string overflowed log buffer ****");
56
     }
57
   va_end(ap);
58
 
59
-  g->size = LOG_BUFFER_SIZE;
60
   g = string_catn(g, US"\n", 1);
61
   debug_printf("%s", string_from_gstring(g));
62
 
63
-  gs.size = LOG_BUFFER_SIZE-1;	/* Having used the buffer for debug output, */
64
+  gs.size = LOG_BUFFER_SIZE-2;	/* Having used the buffer for debug output, */
65
   gs.ptr = 0;			/* reset it for the real use. */
66
   gs.s = log_buffer;
67
   }
68
 /* If no log file is specified, we are in a mess. */
69
 
70
@@ -1035,10 +1034,12 @@ if (  flags & LOG_RECIPIENTS
71
     if (LOG_BUFFER_SIZE - g->ptr < Ustrlen(s) + 3) break;
72
     g = string_fmt_append_f(g, SVFMT_TAINT_NOCHK, " %s", s);
73
     }
74
   }
75
 
76
+/* actual size, now we are placing the newline (and space for NUL) */
77
+gs.size = LOG_BUFFER_SIZE;
78
 g = string_catn(g, US"\n", 1);
79
 string_from_gstring(g);
80
 
81
 /* Handle loggable errors when running a utility, or when address testing.
82
 Write to log_stderr unless debugging (when it will already have been written),
(-)a/mail/exim/files/debian/75_55-Fix-recursion-on-dns_again_means_nonexist.-Bug-2911.patch (-76 lines)
Removed Link Here
1
From 1d38781da934809e6ce0b8c3718c4b3bccdfe1d2 Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Wed, 28 Dec 2022 19:39:06 +0000
4
Subject: [PATCH] Fix recursion on dns_again_means_nonexist. Bug 2911
5
6
---
7
 doc/ChangeLog        |  8 +++++
8
 src/dns.c                | 12 ++++++++
9
 test/confs/2202              | 18 +++++++++--
10
 test/scripts/2200-dnsdb/2202 |  8 +++++
11
 test/stderr/2202             | 58 +++++++++++++++++++++++++++++++++++-
12
 test/stdout/2202             |  8 +++++
13
 6 files changed, 108 insertions(+), 4 deletions(-)
14
15
--- a/doc/ChangeLog
16
+++ b/doc/ChangeLog
17
@@ -33,10 +33,18 @@ JH/14 Bug 2933: Fix regex substring matc
18
 JH/18 Fix a fencepost error in logging.  Previously (since 4.92) when a log line
19
       was exactly sized compared to the log buffer, a crash occurred with the
20
       misleading message "bad memory reference; pool not found".
21
       Found and traced by Jasen Betts.
22
 
23
+JH/19 Bug 2911: Fix a recursion in DNS lookups.  Previously, if the main option
24
+      dns_again_means_nonexist included an element causing a DNS lookup which
25
+      iteslf returned DNS_AGAIN, unbounded recursion occurred.  Possible results
26
+      included (though probably not limited to) a process crash from stack
27
+      memory limit, or from excessive open files.  Replace this with a paniclog
28
+      whine (as this is likely a configuration error), and returning
29
+      DNS_NOMATCH.
30
+
31
 
32
 
33
 Exim version 4.96
34
 -----------------
35
 
36
--- a/src/dns.c
37
+++ b/src/dns.c
38
@@ -799,10 +799,11 @@ int
39
 dns_basic_lookup(dns_answer * dnsa, const uschar * name, int type)
40
 {
41
 int rc;
42
 #ifndef STAND_ALONE
43
 const uschar * save_domain;
44
+static BOOL try_again_recursion = FALSE;
45
 #endif
46
 
47
 /* DNS lookup failures of any kind are cached in a tree. This is mainly so that
48
 a timeout on one domain doesn't happen time and time again for messages that
49
 have many addresses in the same domain. We rely on the resolver and name server
50
@@ -903,15 +904,26 @@ if (dnsa->answerlen < 0) switch (h_errno
51
     DEBUG(D_dns) debug_printf("DNS lookup of %s (%s) gave TRY_AGAIN\n",
52
       name, dns_text_type(type));
53
 
54
     /* Cut this out for various test programs */
55
 #ifndef STAND_ALONE
56
+    if (try_again_recursion)
57
+      {
58
+      log_write(0, LOG_MAIN|LOG_PANIC,
59
+	"dns_again_means_nonexist recursion seen for %s (assuming nonexist)",
60
+	name);
61
+      return dns_fail_return(name, type, dns_expire_from_soa(dnsa, type), DNS_NOMATCH);
62
+      }
63
+
64
+    try_again_recursion = TRUE;
65
     save_domain = deliver_domain;
66
     deliver_domain = string_copy(name);  /* set $domain */
67
     rc = match_isinlist(name, CUSS &dns_again_means_nonexist, 0,
68
       &domainlist_anchor, NULL, MCL_DOMAIN, TRUE, NULL);
69
     deliver_domain = save_domain;
70
+    try_again_recursion = FALSE;
71
+
72
     if (rc != OK)
73
       {
74
       DEBUG(D_dns) debug_printf("returning DNS_AGAIN\n");
75
       return dns_fail_return(name, type, 0, DNS_AGAIN);
76
       }
(-)a/mail/exim/files/debian/75_60-OpenSSL-fix-tls_eccurve-setting-explicit-curve-group.patch (-184 lines)
Removed Link Here
1
From ca4014de81e6aa367aa0a54c49b4c3d4b137814c Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Sun, 1 Jan 2023 12:18:38 +0000
4
Subject: [PATCH] OpenSSL: fix tls_eccurve setting explicit curve/group.  Bug
5
 2954
6
7
---
8
 doc/ChangeLog          |  4 +++
9
 src/tls-openssl.c          | 39 ++++++++++++++----------
10
 test/confs/2148                | 54 ++++++++++++++++++++++++++++++++++
11
 test/confs/2149                | 39 +++++++++++++-----------
12
 test/log/2148                  | 48 ++++++++++++++++++++++++++++++
13
 test/log/2149                  | 39 ++++++++++++------------
14
 test/paniclog/{2149 => 2148}   |  0
15
 test/scripts/2100-OpenSSL/2148 | 50 +++++++++++++++++++++++++++++++
16
 test/scripts/2100-OpenSSL/2149 | 50 ++++++++++++++++---------------
17
 test/stderr/2148               |  5 ++++
18
 test/stderr/2149               |  3 --
19
 11 files changed, 250 insertions(+), 81 deletions(-)
20
 create mode 100644 test/confs/2148
21
 create mode 100644 test/log/2148
22
 rename test/paniclog/{2149 => 2148} (100%)
23
 create mode 100644 test/scripts/2100-OpenSSL/2148
24
 create mode 100644 test/stderr/2148
25
26
--- a/doc/ChangeLog
27
+++ b/doc/ChangeLog
28
@@ -41,10 +41,14 @@ JH/19 Bug 2911: Fix a recursion in DNS l
29
       included (though probably not limited to) a process crash from stack
30
       memory limit, or from excessive open files.  Replace this with a paniclog
31
       whine (as this is likely a configuration error), and returning
32
       DNS_NOMATCH.
33
 
34
+JH/20 Bug 2954: (OpenSSL) Fix setting of explicit EC curve/group.  Previously
35
+      this always failed, probably leading to the usual downgrade to in-clear
36
+      connections.
37
+
38
 
39
 
40
 Exim version 4.96
41
 -----------------
42
 
43
--- a/src/tls-openssl.c
44
+++ b/src/tls-openssl.c
45
@@ -657,16 +657,16 @@ if (dh_bitsize <= tls_dh_max_bits)
46
     /* EVP_PKEY_free(pkey);  crashes */
47
 #endif
48
     }
49
   else
50
     DEBUG(D_tls)
51
-      debug_printf("Diffie-Hellman initialized from %s with %d-bit prime\n",
52
+      debug_printf(" Diffie-Hellman initialized from %s with %d-bit prime\n",
53
 	dhexpanded ? dhexpanded : US"default", dh_bitsize);
54
   }
55
 else
56
   DEBUG(D_tls)
57
-    debug_printf("dhparams '%s' %d bits, is > tls_dh_max_bits limit of %d\n",
58
+    debug_printf(" dhparams '%s' %d bits, is > tls_dh_max_bits limit of %d\n",
59
 	dhexpanded ? dhexpanded : US"default", dh_bitsize, tls_dh_max_bits);
60
 
61
 #if OPENSSL_VERSION_NUMBER < 0x30000000L
62
 DH_free(dh);
63
 #endif
64
@@ -712,23 +712,31 @@ init_ecdh(SSL_CTX * sctx, uschar ** errs
65
 #ifdef OPENSSL_NO_ECDH
66
 return TRUE;
67
 #else
68
 
69
 uschar * exp_curve;
70
-int nid;
71
-BOOL rv;
72
+int nid, rc;
73
 
74
 # ifndef EXIM_HAVE_ECDH
75
 DEBUG(D_tls)
76
-  debug_printf("No OpenSSL API to define ECDH parameters, skipping\n");
77
+  debug_printf(" No OpenSSL API to define ECDH parameters, skipping\n");
78
 return TRUE;
79
 # else
80
 
81
 if (!expand_check(tls_eccurve, US"tls_eccurve", &exp_curve, errstr))
82
   return FALSE;
83
+
84
+/* Is the option deliberately empty? */
85
+
86
 if (!exp_curve || !*exp_curve)
87
+  {
88
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L
89
+  DEBUG(D_tls) debug_printf( " ECDH OpenSSL 1.0.2+: clearing curves list\n");
90
+  (void) SSL_CTX_set1_curves(sctx, &nid, 0);
91
+#endif
92
   return TRUE;
93
+  }
94
 
95
 /* "auto" needs to be handled carefully.
96
  * OpenSSL <  1.0.2: we do not select anything, but fallback to prime256v1
97
  * OpenSSL <  1.1.0: we have to call SSL_CTX_set_ecdh_auto
98
  *                   (openssl/ssl.h defines SSL_CTRL_SET_ECDH_AUTO)
99
@@ -737,27 +745,26 @@ if (!exp_curve || !*exp_curve)
100
  */
101
 if (Ustrcmp(exp_curve, "auto") == 0)
102
   {
103
 #if OPENSSL_VERSION_NUMBER < 0x10002000L
104
   DEBUG(D_tls) debug_printf(
105
-    "ECDH OpenSSL < 1.0.2: temp key parameter settings: overriding \"auto\" with \"prime256v1\"\n");
106
+    " ECDH OpenSSL < 1.0.2: temp key parameter settings: overriding \"auto\" with \"prime256v1\"\n");
107
   exp_curve = US"prime256v1";
108
 #else
109
 # if defined SSL_CTRL_SET_ECDH_AUTO
110
   DEBUG(D_tls) debug_printf(
111
-    "ECDH OpenSSL 1.0.2+: temp key parameter settings: autoselection\n");
112
+    " ECDH OpenSSL 1.0.2+: temp key parameter settings: autoselection\n");
113
   SSL_CTX_set_ecdh_auto(sctx, 1);
114
   return TRUE;
115
 # else
116
   DEBUG(D_tls) debug_printf(
117
-    "ECDH OpenSSL 1.1.0+: temp key parameter settings: default selection\n");
118
+    " ECDH OpenSSL 1.1.0+: temp key parameter settings: library default selection\n");
119
   return TRUE;
120
 # endif
121
 #endif
122
   }
123
 
124
-DEBUG(D_tls) debug_printf("ECDH: curve '%s'\n", exp_curve);
125
 if (  (nid = OBJ_sn2nid       (CCS exp_curve)) == NID_undef
126
 #   ifdef EXIM_HAVE_OPENSSL_EC_NIST2NID
127
    && (nid = EC_curve_nist2nid(CCS exp_curve)) == NID_undef
128
 #   endif
129
    )
130
@@ -777,27 +784,27 @@ if (  (nid = OBJ_sn2nid       (CCS exp_c
131
     }
132
 
133
   /* The "tmp" in the name here refers to setting a temporary key
134
   not to the stability of the interface. */
135
 
136
-  if ((rv = SSL_CTX_set_tmp_ecdh(sctx, ecdh) == 0))
137
+  if ((rc = SSL_CTX_set_tmp_ecdh(sctx, ecdh) == 0))
138
     tls_error(string_sprintf("Error enabling '%s' curve", exp_curve), NULL, NULL, errstr);
139
   else
140
-    DEBUG(D_tls) debug_printf("ECDH: enabled '%s' curve\n", exp_curve);
141
+    DEBUG(D_tls) debug_printf(" ECDH: enabled '%s' curve\n", exp_curve);
142
   EC_KEY_free(ecdh);
143
  }
144
 
145
 #else	/* v 3.0.0 + */
146
 
147
-if ((rv = SSL_CTX_set1_groups(sctx, &nid, 1)) == 0)
148
+if ((rc = SSL_CTX_set1_groups(sctx, &nid, 1)) == 0)
149
   tls_error(string_sprintf("Error enabling '%s' group", exp_curve), NULL, NULL, errstr);
150
 else
151
-  DEBUG(D_tls) debug_printf("ECDH: enabled '%s' group\n", exp_curve);
152
+  DEBUG(D_tls) debug_printf(" ECDH: enabled '%s' group\n", exp_curve);
153
 
154
 #endif
155
 
156
-return !rv;
157
+return !!rc;
158
 
159
 # endif	/*EXIM_HAVE_ECDH*/
160
 #endif /*OPENSSL_NO_ECDH*/
161
 }
162
 
163
@@ -1719,19 +1726,19 @@ state_server.lib_state.lib_ctx = ctx;
164
 
165
 /* Preload DH params and EC curve */
166
 
167
 if (opt_unset_or_noexpand(tls_dhparam))
168
   {
169
-  DEBUG(D_tls) debug_printf("TLS: preloading DH params for server\n");
170
+  DEBUG(D_tls) debug_printf("TLS: preloading DH params '%s' for server\n", tls_dhparam);
171
   if (init_dh(ctx, tls_dhparam, &dummy_errstr))
172
     state_server.lib_state.dh = TRUE;
173
   }
174
 else
175
   DEBUG(D_tls) debug_printf("TLS: not preloading DH params for server\n");
176
 if (opt_unset_or_noexpand(tls_eccurve))
177
   {
178
-  DEBUG(D_tls) debug_printf("TLS: preloading ECDH curve for server\n");
179
+  DEBUG(D_tls) debug_printf("TLS: preloading ECDH curve '%s' for server\n", tls_eccurve);
180
   if (init_ecdh(ctx, &dummy_errstr))
181
     state_server.lib_state.ecdh = TRUE;
182
   }
183
 else
184
   DEBUG(D_tls) debug_printf("TLS: not preloading ECDH curve for server\n");
(-)a/mail/exim/files/debian/75_62-OpenSSL-Fix-tls_eccurve-on-earlier-versions-than-3.0.patch (-42 lines)
Removed Link Here
1
From 7fa5764c203f2f4a900898a79ed02d674075313f Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Mon, 2 Jan 2023 15:04:14 +0000
4
Subject: [PATCH 1/3] OpenSSL: Fix tls_eccurve on earlier versions than 3.0.0. 
5
 Bug 2954
6
7
Broken-by: ca4014de81e6
8
---
9
 src/tls-openssl.c          |  7 ++++---
10
 test/log/2149                  | 28 ++++++++++++++--------------
11
 test/runtest                   |  3 +++
12
 test/scripts/2100-OpenSSL/2149 | 22 ++++++++++++----------
13
 4 files changed, 33 insertions(+), 27 deletions(-)
14
15
diff --git a/src/tls-openssl.c b/src/tls-openssl.c
16
index 4d0f99ea9..e063d29bd 100644
17
--- a/src/tls-openssl.c
18
+++ b/src/tls-openssl.c
19
@@ -786,8 +786,9 @@ if (  (nid = OBJ_sn2nid       (CCS exp_curve)) == NID_undef
20
 #   endif
21
    )
22
   {
23
-  tls_error(string_sprintf("Unknown curve name tls_eccurve '%s'", exp_curve),
24
-    NULL, NULL, errstr);
25
+  uschar * s = string_sprintf("Unknown curve name tls_eccurve '%s'", exp_curve);
26
+  DEBUG(D_tls) debug_printf("TLS error '%s'\n", s);
27
+  if (errstr) *errstr = s;
28
   return FALSE;
29
   }
30
 
31
@@ -803,7 +804,7 @@ if (  (nid = OBJ_sn2nid       (CCS exp_curve)) == NID_undef
32
   /* The "tmp" in the name here refers to setting a temporary key
33
   not to the stability of the interface. */
34
 
35
-  if ((rc = SSL_CTX_set_tmp_ecdh(sctx, ecdh) == 0))
36
+  if ((rc = SSL_CTX_set_tmp_ecdh(sctx, ecdh)) == 0)
37
     tls_error(string_sprintf("Error enabling '%s' curve", exp_curve), NULL, NULL, errstr);
38
   else
39
     DEBUG(D_tls) debug_printf(" ECDH: enabled '%s' curve\n", exp_curve);
40
-- 
41
2.39.0
42
(-)a/mail/exim/files/debian/75_64-DANE-do-not-check-dns_again_means_nonexist-for-TLSA-.patch (-96 lines)
Removed Link Here
1
From 30520c8f87fcf660ed99a2344cae7f9787f7bc89 Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Thu, 5 Jan 2023 18:39:51 +0000
4
Subject: [PATCH 3/3] DANE: do not check dns_again_means_nonexist for TLSA
5
 results of TRY_AGAIN
6
7
---
8
 doc/doc-docbook/spec.xfpt |  7 ++++++-
9
 doc/ChangeLog     |  4 ++++
10
 src/dns.c             | 35 ++++++++++++++++++++++-------------
11
 3 files changed, 32 insertions(+), 14 deletions(-)
12
13
--- a/doc/ChangeLog
14
+++ b/doc/ChangeLog
15
@@ -46,10 +46,14 @@ JH/19 Bug 2911: Fix a recursion in DNS l
16
 JH/20 Bug 2954: (OpenSSL) Fix setting of explicit EC curve/group.  Previously
17
       this always failed, probably leading to the usual downgrade to in-clear
18
       connections.
19
 
20
 
21
+JH/20 Fix TLSA lookups.  Previously dns_again_means_nonexist would affect
22
+      SERVFAIL results, which breaks the downgrade resistance of DANE.  Change
23
+      to not checking that list for these looks.
24
+
25
 
26
 Exim version 4.96
27
 -----------------
28
 
29
 JH/01 Move the wait-for-next-tick (needed for unique message IDs) from
30
--- a/src/dns.c
31
+++ b/src/dns.c
32
@@ -904,25 +904,34 @@ if (dnsa->answerlen < 0) switch (h_errno
33
     DEBUG(D_dns) debug_printf("DNS lookup of %s (%s) gave TRY_AGAIN\n",
34
       name, dns_text_type(type));
35
 
36
     /* Cut this out for various test programs */
37
 #ifndef STAND_ALONE
38
-    if (try_again_recursion)
39
+    /* Permitting dns_again_means nonexist for TLSA lookups breaks the
40
+    doewngrade resistance of dane, so avoid for those. */
41
+
42
+    if (type == T_TLSA)
43
+      rc = FAIL;
44
+    else
45
       {
46
-      log_write(0, LOG_MAIN|LOG_PANIC,
47
-	"dns_again_means_nonexist recursion seen for %s (assuming nonexist)",
48
-	name);
49
-      return dns_fail_return(name, type, dns_expire_from_soa(dnsa, type), DNS_NOMATCH);
50
-      }
51
+      if (try_again_recursion)
52
+	{
53
+	log_write(0, LOG_MAIN|LOG_PANIC,
54
+	  "dns_again_means_nonexist recursion seen for %s"
55
+	  " (assuming nonexist)", name);
56
+	return dns_fail_return(name, type, dns_expire_from_soa(dnsa, type),
57
+			      DNS_NOMATCH);
58
+	}
59
 
60
-    try_again_recursion = TRUE;
61
-    save_domain = deliver_domain;
62
-    deliver_domain = string_copy(name);  /* set $domain */
63
-    rc = match_isinlist(name, CUSS &dns_again_means_nonexist, 0,
64
-      &domainlist_anchor, NULL, MCL_DOMAIN, TRUE, NULL);
65
-    deliver_domain = save_domain;
66
-    try_again_recursion = FALSE;
67
+      try_again_recursion = TRUE;
68
+      save_domain = deliver_domain;
69
+      deliver_domain = string_copy(name);  /* set $domain */
70
+      rc = match_isinlist(name, CUSS &dns_again_means_nonexist, 0,
71
+	&domainlist_anchor, NULL, MCL_DOMAIN, TRUE, NULL);
72
+      deliver_domain = save_domain;
73
+      try_again_recursion = FALSE;
74
+      }
75
 
76
     if (rc != OK)
77
       {
78
       DEBUG(D_dns) debug_printf("returning DNS_AGAIN\n");
79
       return dns_fail_return(name, type, 0, DNS_AGAIN);
80
--- a/doc/spec.txt
81
+++ b/doc/spec.txt
82
@@ -14246,11 +14246,13 @@ dns_again_means_nonexist, it is treated
83
 should be used with care. You can make it apply to reverse lookups by a setting
84
 such as this:
85
 
86
 dns_again_means_nonexist = *.in-addr.arpa
87
 
88
-This option applies to all DNS lookups that Exim does. It also applies when the
89
+This option applies to all DNS lookups that Exim does, except for TLSA lookups
90
+(where knowing about such failures +is security-relevant). It also applies
91
+when the
92
 gethostbyname() or getipnodebyname() functions give temporary errors, since
93
 these are most likely to be caused by DNS lookup problems. The dnslookup router
94
 has some options of its own for controlling what happens when lookups for MX or
95
 SRV records give temporary errors. These more specific options are applied
96
 after this global option.
(-)a/mail/exim/files/debian/75_66-Fix-crash-in-expansions.patch (-84 lines)
Removed Link Here
1
From 70069b65a39a7ba73a36fbd95371ff03cde1eb23 Mon Sep 17 00:00:00 2001
2
From: Jeremy Harris <jgh146exb@wizmail.org>
3
Date: Thu, 2 Feb 2023 20:00:35 +0000
4
Subject: [PATCH] Fix crash in expansions
5
6
Broken-by: 1058096b8c53
7
---
8
 doc/ChangeLog | 4 ++++
9
 src/expand.c      | 9 +++++----
10
 test/stderr/0630      | 1 +
11
 3 files changed, 10 insertions(+), 4 deletions(-)
12
13
--- a/doc/ChangeLog
14
+++ b/doc/ChangeLog
15
@@ -50,10 +50,14 @@ JH/20 Bug 2954: (OpenSSL) Fix setting of
16
 
17
 JH/20 Fix TLSA lookups.  Previously dns_again_means_nonexist would affect
18
       SERVFAIL results, which breaks the downgrade resistance of DANE.  Change
19
       to not checking that list for these looks.
20
 
21
+JH/23 Fix crash in string expansions. Previously, if an empty variable was
22
+      immediately followed by an expansion operator, a null-indirection read
23
+      was done, killing the process.
24
+
25
 
26
 Exim version 4.96
27
 -----------------
28
 
29
 JH/01 Move the wait-for-next-tick (needed for unique message IDs) from
30
--- a/src/expand.c
31
+++ b/src/expand.c
32
@@ -4652,11 +4652,11 @@ while (*s)
33
       yield = string_catn(yield, value, len);
34
 
35
     continue;
36
     }
37
 
38
-  if (isdigit(*s))
39
+  if (isdigit(*s))		/* A $<n> variable */
40
     {
41
     int n;
42
     s = read_cnumber(&n, s);
43
     if (n >= 0 && n <= expand_nmax)
44
       yield = string_catn(yield, expand_nstring[n], expand_nlength[n]);
45
@@ -7060,10 +7060,11 @@ NOT_ITEM: ;
46
       if (arg) *arg++ = '_';		/* Put back for error messages */
47
       }
48
 
49
     /* Deal specially with operators that might take a certificate variable
50
     as we do not want to do the usual expansion. For most, expand the string.*/
51
+
52
     switch(c)
53
       {
54
 #ifndef DISABLE_TLS
55
       case EOP_MD5:
56
       case EOP_SHA1:
57
@@ -7107,11 +7108,11 @@ NOT_ITEM: ;
58
 
59
     /* Otherwise, switch on the operator type.  After handling go back
60
     to the main loop top. */
61
 
62
      {
63
-     int start = yield->ptr;
64
+     unsigned expansion_start = gstring_length(yield);
65
      switch(c)
66
       {
67
       case EOP_BASE32:
68
 	{
69
 	uschar *t;
70
@@ -8168,12 +8169,12 @@ NOT_ITEM: ;
71
 	  goto EXPAND_FAILED;
72
 	}	/* EOP_* switch */
73
 
74
        DEBUG(D_expand)
75
 	{
76
-	const uschar * s = yield->s + start;
77
-	int i = yield->ptr - start;
78
+	const uschar * s = yield->s + expansion_start;
79
+	int i = gstring_length(yield) - expansion_start;
80
 	BOOL tainted = is_tainted(s);
81
 
82
 	DEBUG(D_noutf8)
83
 	  {
84
 	  debug_printf_indent("|-----op-res: %.*s\n", i, s);

Return to bug 274235