Open
[sync] PR-24: fix CVE-2024-39929 #31
openeuler-ci-botAdd on Feb 11
[sync] PR-24: fix CVE-2024-39929 #31
Open
openeuler-ci-botAdd on Feb 11
Total: 3 files changed+620-2
@@ -0,0 +1,172 @@
1+From 6ce5c70cff8989418e05d01fd2a57703007a6357 Mon Sep 17 00:00:00 2001
2+From: Jeremy Harris <jgh146exb@wizmail.org>
3+Date: Thu, 17 Oct 2024 11:47:59 +0800
4+Subject: [PATCH] Fix MIME parsing of filenames specified using multiple
5+ parameters. Bug 3099
6+---
7+ doc/ChangeLog | 3 +++
8+ doc/spec.txt | 10 +++++-----
9+ src/mime.c | 53 ++++++++++++++++++++++++++++-----------------------
10+ src/string.c | 1 +
11+ 4 files changed, 38 insertions(+), 29 deletions(-)
12+ 
13+diff --git a/doc/ChangeLog b/doc/ChangeLog
14+index c88454c..635f408 100644
15+--- a/doc/ChangeLog
16++++ b/doc/ChangeLog
17+@@ -221,6 +221,9 @@ JH/43 Bug 2903: avoid exit on an attempt to rewrite a malformed address.
18+ JH/44 Bug 3033: Harden dnsdb lookups against crafted DNS responses.
19+ CVE-2023-42219
20+
21++JH/45 Bug 3099: fix parsing of MIME filenames split over multiple paramemters.
22++ Previously the $mime_filename variable would have an incorrect value.
23++
24+ HS/02 Fix string_is_ip_address() CVE-2023-42117 (Bug 3031)
25+
26+ Exim version 4.96
27+diff --git a/doc/spec.txt b/doc/spec.txt
28+index 6bb656e..8f598e7 100644
29+--- a/doc/spec.txt
30++++ b/doc/spec.txt
31+@@ -32280,13 +32280,13 @@ The right hand side is expanded before use. After expansion, the value can be:
32+ the default path is then used.
33+
34+ The decode condition normally succeeds. It is only false for syntax errors or
35+-unusual circumstances such as memory shortages. You can easily decode a file
36+-with its original, proposed filename using
37++errors or unusual circumstances such as memory shortages.
38+
39+-decode = $mime_filename
40++The variable &$mime_filename$& will have the suggested name for the file.
41++Note however that this might contain anything, and is very difficult
42++to safely use as all or even part of the filename.
43+
44+-However, you should keep in mind that $mime_filename might contain anything. If
45+-you place files outside of the default path, they are not automatically
46++If you place files outside of the default path, they are not
47+ unlinked.
48+
49+ For RFC822 attachments (these are messages attached to messages, with a
50+diff --git a/src/mime.c b/src/mime.c
51+index 975ddca..b11959c 100644
52+--- a/src/mime.c
53++++ b/src/mime.c
54+@@ -587,10 +587,10 @@ while(1)
55+
56+ while (*p)
57+ {
58+- DEBUG(D_acl) debug_printf_indent("MIME: considering paramlist '%s'\n", p);
59++ DEBUG(D_acl)
60++ debug_printf_indent("MIME: considering paramlist '%s'\n", p);
61+
62+- if ( !mime_filename
63+- && strncmpic(CUS"content-disposition:", header, 20) == 0
64++ if ( strncmpic(CUS"content-disposition:", header, 20) == 0
65+ && strncmpic(CUS"filename*", p, 9) == 0
66+ )
67+ { /* RFC 2231 filename */
68+@@ -604,12 +604,12 @@ while(1)
69+
70+ if (q && *q)
71+ {
72+- uschar * temp_string, * err_msg;
73++ uschar * temp_string, * err_msg, * fname = q;
74+ int slen;
75+
76+ /* build up an un-decoded filename over successive
77+ filename*= parameters (for use when 2047 decode fails) */
78+-
79++/*XXX could grow a gstring here */
80+ mime_fname_rfc2231 = string_sprintf("%#s%s",
81+ mime_fname_rfc2231, q);
82+
83+@@ -623,26 +623,31 @@ while(1)
84+ /* look for a ' in the "filename" */
85+ while(*s != '\'' && *s) s++; /* s is 1st ' or NUL */
86+
87+- if ((size = s-q) > 0)
88+- mime_filename_charset = string_copyn(q, size);
89+-
90+- if (*(p = s)) p++;
91+- while(*p == '\'') p++; /* p is after 2nd ' */
92++ if (*s) /* there was a ' */
93++ {
94++ if ((size = s-q) > 0)
95++ mime_filename_charset = string_copyn(q, size);
96++ if (*(fname = s)) fname++;
97++ while(*fname == '\'') fname++; /* fname is after 2nd ' */
98++ }
99+ }
100+- else
101+- p = q;
102+
103+- DEBUG(D_acl) debug_printf_indent("MIME: charset %s fname '%s'\n",
104+- mime_filename_charset ? mime_filename_charset : US"<NULL>", p);
105++ DEBUG(D_acl)
106++ debug_printf_indent("MIME: charset %s fname '%s'\n",
107++ mime_filename_charset ? mime_filename_charset : US"<NULL>",
108++ fname);
109+
110+- temp_string = rfc2231_to_2047(p, mime_filename_charset, &slen);
111+- DEBUG(D_acl) debug_printf_indent("MIME: 2047-name %s\n", temp_string);
112++ temp_string = rfc2231_to_2047(fname, mime_filename_charset,
113++ &slen);
114++ DEBUG(D_acl)
115++ debug_printf_indent("MIME: 2047-name %s\n", temp_string);
116+
117+ temp_string = rfc2047_decode(temp_string, FALSE, NULL, ' ',
118+- NULL, &err_msg);
119+- DEBUG(D_acl) debug_printf_indent("MIME: plain-name %s\n", temp_string);
120++ NULL, &err_msg);
121++ DEBUG(D_acl)
122++ debug_printf_indent("MIME: plain-name %s\n", temp_string);
123+
124+- if (!temp_string || (size = Ustrlen(temp_string)) == slen)
125++ if (!temp_string || (size = Ustrlen(temp_string)) == slen)
126+ decoding_failed = TRUE;
127+ else
128+ /* build up a decoded filename over successive
129+@@ -651,9 +656,9 @@ while(1)
130+ mime_filename = mime_fname = mime_fname
131+ ? string_sprintf("%s%s", mime_fname, temp_string)
132+ : temp_string;
133+- }
134+- }
135+- }
136++ } /*!decoding_failed*/
137++ } /*q*/
138++ } /*2231 filename*/
139+
140+ else
141+ /* look for interesting parameters */
142+@@ -682,7 +687,7 @@ while(1)
143+
144+
145+ /* There is something, but not one of our interesting parameters.
146+- Advance past the next semicolon */
147++ Advance past the next semicolon */
148+ p = mime_next_semicolon(p);
149+ if (*p) p++;
150+ } /* param scan on line */
151+@@ -800,5 +805,5 @@ return rc;
152+
153+ #endif /*WITH_CONTENT_SCAN*/
154+
155+-/* vi: sw ai sw=2
156++/* vi: aw ai sw=2
157+ */
158+diff --git a/src/string.c b/src/string.c
159+index dfe0f24..2f77cc7 100644
160+--- a/src/string.c
161++++ b/src/string.c
162+@@ -1347,6 +1347,7 @@ Field width: decimal digits, or *
163+ Precision: dot, followed by decimal digits or *
164+ Length modifiers: h L l ll z
165+ Conversion specifiers: n d o u x X p f e E g G % c s S T Y D M
166++Alternate-form: %#s is silent about a null string
167+
168+ Returns the possibly-new (if copy for growth or taint-handling was needed)
169+ string, not nul-terminated.
170+--
171+2.43.0
172+ 
@@ -0,0 +1,440 @@
1+From 1b3209b0577a9327ebb076f3b32b8a159c253f7b Mon Sep 17 00:00:00 2001
2+From: Jeremy Harris <jgh146exb@wizmail.org>
3+Date: Thu, 17 Oct 2024 13:55:10 +0800
4+Subject: [PATCH] MIME: support RFC 2331 for name=. Bug 3099
5+ 
6+---
7+ ...-specified-using-multiple-parameters.patch | 172 +++++++++++++++++
8+ doc/ChangeLog | 2 +
9+ src/mime.c | 180 +++++++++---------
10+ 3 files changed, 267 insertions(+), 87 deletions(-)
11+ create mode 100644 backport-bug3099-Fix-MIME-parsing-of-filenames-specified-using-multiple-parameters.patch
12+ 
13+diff --git a/backport-bug3099-Fix-MIME-parsing-of-filenames-specified-using-multiple-parameters.patch b/backport-bug3099-Fix-MIME-parsing-of-filenames-specified-using-multiple-parameters.patch
14+new file mode 100644
15+index 0000000..bded9f0
16+--- /dev/null
17++++ b/backport-bug3099-Fix-MIME-parsing-of-filenames-specified-using-multiple-parameters.patch
18+@@ -0,0 +1,172 @@
19++From 6ce5c70cff8989418e05d01fd2a57703007a6357 Mon Sep 17 00:00:00 2001
20++From: Jeremy Harris <jgh146exb@wizmail.org>
21++Date: Thu, 17 Oct 2024 11:47:59 +0800
22++Subject: [PATCH] Fix MIME parsing of filenames specified using multiple
23++ parameters. Bug 3099
24++---
25++ doc/ChangeLog | 3 +++
26++ doc/spec.txt | 10 +++++-----
27++ src/mime.c | 53 ++++++++++++++++++++++++++++-----------------------
28++ src/string.c | 1 +
29++ 4 files changed, 38 insertions(+), 29 deletions(-)
30++
31++diff --git a/doc/ChangeLog b/doc/ChangeLog
32++index c88454c..635f408 100644
33++--- a/doc/ChangeLog
34+++++ b/doc/ChangeLog
35++@@ -221,6 +221,9 @@ JH/43 Bug 2903: avoid exit on an attempt to rewrite a malformed address.
36++ JH/44 Bug 3033: Harden dnsdb lookups against crafted DNS responses.
37++ CVE-2023-42219
38++
39+++JH/45 Bug 3099: fix parsing of MIME filenames split over multiple paramemters.
40+++ Previously the $mime_filename variable would have an incorrect value.
41+++
42++ HS/02 Fix string_is_ip_address() CVE-2023-42117 (Bug 3031)
43++
44++ Exim version 4.96
45++diff --git a/doc/spec.txt b/doc/spec.txt
46++index 6bb656e..8f598e7 100644
47++--- a/doc/spec.txt
48+++++ b/doc/spec.txt
49++@@ -32280,13 +32280,13 @@ The right hand side is expanded before use. After expansion, the value can be:
50++ the default path is then used.
51++
52++ The decode condition normally succeeds. It is only false for syntax errors or
53++-unusual circumstances such as memory shortages. You can easily decode a file
54++-with its original, proposed filename using
55+++errors or unusual circumstances such as memory shortages.
56++
57++-decode = $mime_filename
58+++The variable &$mime_filename$& will have the suggested name for the file.
59+++Note however that this might contain anything, and is very difficult
60+++to safely use as all or even part of the filename.
61++
62++-However, you should keep in mind that $mime_filename might contain anything. If
63++-you place files outside of the default path, they are not automatically
64+++If you place files outside of the default path, they are not
65++ unlinked.
66++
67++ For RFC822 attachments (these are messages attached to messages, with a
68++diff --git a/src/mime.c b/src/mime.c
69++index 975ddca..b11959c 100644
70++--- a/src/mime.c
71+++++ b/src/mime.c
72++@@ -587,10 +587,10 @@ while(1)
73++
74++ while (*p)
75++ {
76++- DEBUG(D_acl) debug_printf_indent("MIME: considering paramlist '%s'\n", p);
77+++ DEBUG(D_acl)
78+++ debug_printf_indent("MIME: considering paramlist '%s'\n", p);
79++
80++- if ( !mime_filename
81++- && strncmpic(CUS"content-disposition:", header, 20) == 0
82+++ if ( strncmpic(CUS"content-disposition:", header, 20) == 0
83++ && strncmpic(CUS"filename*", p, 9) == 0
84++ )
85++ { /* RFC 2231 filename */
86++@@ -604,12 +604,12 @@ while(1)
87++
88++ if (q && *q)
89++ {
90++- uschar * temp_string, * err_msg;
91+++ uschar * temp_string, * err_msg, * fname = q;
92++ int slen;
93++
94++ /* build up an un-decoded filename over successive
95++ filename*= parameters (for use when 2047 decode fails) */
96++-
97+++/*XXX could grow a gstring here */
98++ mime_fname_rfc2231 = string_sprintf("%#s%s",
99++ mime_fname_rfc2231, q);
100++
101++@@ -623,26 +623,31 @@ while(1)
102++ /* look for a ' in the "filename" */
103++ while(*s != '\'' && *s) s++; /* s is 1st ' or NUL */
104++
105++- if ((size = s-q) > 0)
106++- mime_filename_charset = string_copyn(q, size);
107++-
108++- if (*(p = s)) p++;
109++- while(*p == '\'') p++; /* p is after 2nd ' */
110+++ if (*s) /* there was a ' */
111+++ {
112+++ if ((size = s-q) > 0)
113+++ mime_filename_charset = string_copyn(q, size);
114+++ if (*(fname = s)) fname++;
115+++ while(*fname == '\'') fname++; /* fname is after 2nd ' */
116+++ }
117++ }
118++- else
119++- p = q;
120++
121++- DEBUG(D_acl) debug_printf_indent("MIME: charset %s fname '%s'\n",
122++- mime_filename_charset ? mime_filename_charset : US"<NULL>", p);
123+++ DEBUG(D_acl)
124+++ debug_printf_indent("MIME: charset %s fname '%s'\n",
125+++ mime_filename_charset ? mime_filename_charset : US"<NULL>",
126+++ fname);
127++
128++- temp_string = rfc2231_to_2047(p, mime_filename_charset, &slen);
129++- DEBUG(D_acl) debug_printf_indent("MIME: 2047-name %s\n", temp_string);
130+++ temp_string = rfc2231_to_2047(fname, mime_filename_charset,
131+++ &slen);
132+++ DEBUG(D_acl)
133+++ debug_printf_indent("MIME: 2047-name %s\n", temp_string);
134++
135++ temp_string = rfc2047_decode(temp_string, FALSE, NULL, ' ',
136++- NULL, &err_msg);
137++- DEBUG(D_acl) debug_printf_indent("MIME: plain-name %s\n", temp_string);
138+++ NULL, &err_msg);
139+++ DEBUG(D_acl)
140+++ debug_printf_indent("MIME: plain-name %s\n", temp_string);
141++
142++- if (!temp_string || (size = Ustrlen(temp_string)) == slen)
143+++ if (!temp_string || (size = Ustrlen(temp_string)) == slen)
144++ decoding_failed = TRUE;
145++ else
146++ /* build up a decoded filename over successive
147++@@ -651,9 +656,9 @@ while(1)
148++ mime_filename = mime_fname = mime_fname
149++ ? string_sprintf("%s%s", mime_fname, temp_string)
150++ : temp_string;
151++- }
152++- }
153++- }
154+++ } /*!decoding_failed*/
155+++ } /*q*/
156+++ } /*2231 filename*/
157++
158++ else
159++ /* look for interesting parameters */
160++@@ -682,7 +687,7 @@ while(1)
161++
162++
163++ /* There is something, but not one of our interesting parameters.
164++- Advance past the next semicolon */
165+++ Advance past the next semicolon */
166++ p = mime_next_semicolon(p);
167++ if (*p) p++;
168++ } /* param scan on line */
169++@@ -800,5 +805,5 @@ return rc;
170++
171++ #endif /*WITH_CONTENT_SCAN*/
172++
173++-/* vi: sw ai sw=2
174+++/* vi: aw ai sw=2
175++ */
176++diff --git a/src/string.c b/src/string.c
177++index dfe0f24..2f77cc7 100644
178++--- a/src/string.c
179+++++ b/src/string.c
180++@@ -1347,6 +1347,7 @@ Field width: decimal digits, or *
181++ Precision: dot, followed by decimal digits or *
182++ Length modifiers: h L l ll z
183++ Conversion specifiers: n d o u x X p f e E g G % c s S T Y D M
184+++Alternate-form: %#s is silent about a null string
185++
186++ Returns the possibly-new (if copy for growth or taint-handling was needed)
187++ string, not nul-terminated.
188++--
189++2.43.0
190++
191+diff --git a/doc/ChangeLog b/doc/ChangeLog
192+index 635f408..5d8b2a1 100644
193+--- a/doc/ChangeLog
194++++ b/doc/ChangeLog
195+@@ -223,6 +223,8 @@ JH/44 Bug 3033: Harden dnsdb lookups against crafted DNS responses.
196+
197+ JH/45 Bug 3099: fix parsing of MIME filenames split over multiple paramemters.
198+ Previously the $mime_filename variable would have an incorrect value.
199++ While in the code, extend coverage to name= which previously was only
200++ supported for single parameters, despite also filling in $mime_filename.
201+
202+ HS/02 Fix string_is_ip_address() CVE-2023-42117 (Bug 3031)
203+
204+diff --git a/src/mime.c b/src/mime.c
205+index b11959c..3319f1d 100644
206+--- a/src/mime.c
207++++ b/src/mime.c
208+@@ -30,10 +30,10 @@ static int mime_header_list_size = nelem(mime_header_list);
209+
210+ static mime_parameter mime_parameter_list[] = {
211+ /* name namelen value */
212+- { US"name=", 5, &mime_filename },
213+- { US"filename=", 9, &mime_filename },
214+- { US"charset=", 8, &mime_charset },
215+- { US"boundary=", 9, &mime_boundary }
216++ { US"name=", 4, &mime_filename },
217++ { US"filename=", 8, &mime_filename },
218++ { US"charset=", 7, &mime_charset },
219++ { US"boundary=", 8, &mime_boundary }
220+ };
221+
222+
223+@@ -577,8 +577,8 @@ while(1)
224+ if (*(p = q)) p++; /* jump past the ; */
225+
226+ {
227+- uschar * mime_fname = NULL;
228+- uschar * mime_fname_rfc2231 = NULL;
229++ gstring * mime_fname = NULL;
230++ gstring * mime_fname_rfc2231 = NULL;
231+ uschar * mime_filename_charset = NULL;
232+ BOOL decoding_failed = FALSE;
233+
234+@@ -590,88 +590,91 @@ while(1)
235+ DEBUG(D_acl)
236+ debug_printf_indent("MIME: considering paramlist '%s'\n", p);
237+
238+- if ( strncmpic(CUS"content-disposition:", header, 20) == 0
239+- && strncmpic(CUS"filename*", p, 9) == 0
240+- )
241+- { /* RFC 2231 filename */
242+- uschar * q;
243+-
244+- /* find value of the filename */
245+- p += 9;
246+- while(*p != '=' && *p) p++;
247+- if (*p) p++; /* p is filename or NUL */
248+- q = mime_param_val(&p); /* p now trailing ; or NUL */
249+-
250+- if (q && *q)
251++ /* look for interesting parameters */
252++ for (mime_parameter * mp = mime_parameter_list;
253++ mp < mime_parameter_list + nelem(mime_parameter_list);
254++ mp++
255++ ) if (strncmpic(mp->name, p, mp->namelen) == 0)
256++ {
257++ p += mp->namelen;
258++ if (*p == '*') /* RFC 2231 */
259+ {
260+- uschar * temp_string, * err_msg, * fname = q;
261+- int slen;
262+-
263+- /* build up an un-decoded filename over successive
264+- filename*= parameters (for use when 2047 decode fails) */
265+-/*XXX could grow a gstring here */
266+- mime_fname_rfc2231 = string_sprintf("%#s%s",
267+- mime_fname_rfc2231, q);
268+-
269+- if (!decoding_failed)
270++ while (isdigit(*++p)) ; /* ignore cont-cnt values */
271++ if (*p == '*') p++; /* step over sep chset mark */
272++ if (*p == '=')
273+ {
274+- int size;
275+- if (!mime_filename_charset)
276++ uschar * q;
277++ p++; /* step over = */
278++ q = mime_param_val(&p); /* p now trailing ; or NUL */
279++
280++ if (q && *q) /* q is the dequoted value */
281+ {
282+- uschar * s = q;
283++ uschar * err_msg, * fname = q;
284++ int slen;
285+
286+- /* look for a ' in the "filename" */
287+- while(*s != '\'' && *s) s++; /* s is 1st ' or NUL */
288++ /* build up an un-decoded filename over successive
289++ filename*= parameters (for use when 2047 decode fails) */
290++ mime_fname_rfc2231 = string_cat(mime_fname_rfc2231, q);
291+
292+- if (*s) /* there was a ' */
293++ if (!decoding_failed)
294+ {
295+- if ((size = s-q) > 0)
296+- mime_filename_charset = string_copyn(q, size);
297+- if (*(fname = s)) fname++;
298+- while(*fname == '\'') fname++; /* fname is after 2nd ' */
299+- }
300+- }
301+-
302+- DEBUG(D_acl)
303+- debug_printf_indent("MIME: charset %s fname '%s'\n",
304+- mime_filename_charset ? mime_filename_charset : US"<NULL>",
305+- fname);
306+-
307+- temp_string = rfc2231_to_2047(fname, mime_filename_charset,
308+- &slen);
309+- DEBUG(D_acl)
310+- debug_printf_indent("MIME: 2047-name %s\n", temp_string);
311+-
312+- temp_string = rfc2047_decode(temp_string, FALSE, NULL, ' ',
313+- NULL, &err_msg);
314+- DEBUG(D_acl)
315+- debug_printf_indent("MIME: plain-name %s\n", temp_string);
316+-
317+- if (!temp_string || (size = Ustrlen(temp_string)) == slen)
318+- decoding_failed = TRUE;
319+- else
320+- /* build up a decoded filename over successive
321+- filename*= parameters */
322+-
323+- mime_filename = mime_fname = mime_fname
324+- ? string_sprintf("%s%s", mime_fname, temp_string)
325+- : temp_string;
326+- } /*!decoding_failed*/
327+- } /*q*/
328+- } /*2231 filename*/
329+-
330+- else
331+- /* look for interesting parameters */
332+- for (mime_parameter * mp = mime_parameter_list;
333+- mp < mime_parameter_list + nelem(mime_parameter_list);
334+- mp++
335+- ) if (strncmpic(mp->name, p, mp->namelen) == 0)
336+- {
337+- uschar * q;
338+- uschar * dummy_errstr;
339++ if (!mime_filename_charset)
340++ { /* try for RFC 2231 chset/lang */
341++ uschar * s = q;
342++
343++ /* look for a ' in the raw paramval */
344++ while(*s != '\'' && *s) s++; /* s is 1st ' or NUL */
345++
346++ if (*s) /* there was a ' */
347++ {
348++ int size;
349++ if ((size = s-q) > 0)
350++ mime_filename_charset = string_copyn(q, size);
351++
352++ if (*(fname = s)) fname++;
353++ while(*fname == '\'') fname++; /*fname is after 2nd '*/
354++ }
355++ }
356++
357++ DEBUG(D_acl)
358++ debug_printf_indent("MIME: charset %s fname '%s'\n",
359++ mime_filename_charset ? mime_filename_charset : US"<NULL>",
360++ fname);
361++
362++ fname = rfc2231_to_2047(fname, mime_filename_charset,
363++ &slen);
364++ DEBUG(D_acl)
365++ debug_printf_indent("MIME: 2047-name %s\n", fname);
366++
367++ fname = rfc2047_decode(fname, FALSE, NULL, ' ',
368++ NULL, &err_msg);
369++ DEBUG(D_acl) debug_printf_indent(
370++ "MIME: plain-name %s\n", fname);
371++
372++ if (!fname || Ustrlen(fname) == slen)
373++ decoding_failed = TRUE;
374++ else if (mp->value == &mime_filename)
375++ {
376++ /* build up a decoded filename over successive
377++ filename*= parameters */
378++
379++ mime_fname = string_cat(mime_fname, fname);
380++ mime_filename = string_from_gstring(mime_fname);
381++ }
382++ } /*!decoding_failed*/
383++ } /*q*/
384++
385++ if (*p) p++; /* p is past ; */
386++ goto param_done; /* done matching param names */
387++ } /*2231 param coding extension*/
388++ }
389++ else if (*p == '=')
390++ { /* non-2231 param */
391++ uschar * q, * dummy_errstr;
392+
393+ /* grab the value and copy to its expansion variable */
394+- p += mp->namelen;
395++
396++ if (*p) p++; /* step over = */
397+ q = mime_param_val(&p); /* p now trailing ; or NUL */
398+
399+ *mp->value = q && *q
400+@@ -682,27 +685,30 @@ while(1)
401+ "MIME: found %s parameter in %s header, value '%s'\n",
402+ mp->name, mh->name, *mp->value);
403+
404+- break; /* done matching param names */
405++ if (*p) p++; /* p is past ; */
406++ goto param_done; /* done matching param names */
407+ }
408+-
409++ } /* interesting parameters */
410+
411+ /* There is something, but not one of our interesting parameters.
412+ Advance past the next semicolon */
413++
414+ p = mime_next_semicolon(p);
415+ if (*p) p++;
416+- } /* param scan on line */
417++ param_done:
418++ } /* param scan on line */
419+
420+ if (strncmpic(CUS"content-disposition:", header, 20) == 0)
421+ {
422+- if (decoding_failed) mime_filename = mime_fname_rfc2231;
423+-
424++ if (decoding_failed)
425++ mime_filename = string_from_gstring(mime_fname_rfc2231);
426+ DEBUG(D_acl) debug_printf_indent(
427+ "MIME: found %s parameter in %s header, value is '%s'\n",
428+ "filename", mh->name, mime_filename);
429+ }
430+ }
431+- }
432+-
433++ break;
434++ } /* interesting headers */
435+ /* set additional flag variables (easier access) */
436+ if ( mime_content_type
437+ && Ustrncmp(mime_content_type,"multipart",9) == 0
438+--
439+2.43.0
440+ 
@@ -4,7 +4,7 @@
4Summary: The exim mail transfer agent4Summary: The exim mail transfer agent
5Name: exim5Name: exim
6Version: 4.97.16Version: 4.97.1
7-Release: 27+Release: 3
8License: GPLv2+8License: GPLv2+
9Url: https://www.exim.org/9Url: https://www.exim.org/
10 10 
@@ -40,6 +40,9 @@ Patch1: exim-4.94-libdir.patch
40Patch2: exim-4.97-dlopen-localscan.patch40Patch2: exim-4.97-dlopen-localscan.patch
41Patch3: exim-4.96-pic.patch41Patch3: exim-4.96-pic.patch
42Patch4: CVE-2023-51766.patch42Patch4: CVE-2023-51766.patch
43+# CVE-2024-39929
44+Patch5: backport-bug3099-Fix-MIME-parsing-of-filenames-specified-using-multiple-parameters.patch
45+Patch6: backport-bug3099-MIME-support-RFC-2331-for-name.patch
43 46 
44Requires: /etc/pki/tls/certs /etc/pki/tls/private47Requires: /etc/pki/tls/certs /etc/pki/tls/private
45Requires: setup48Requires: setup
@@ -480,6 +483,9 @@ fi
480%{_sysconfdir}/cron.daily/greylist-tidy.sh483%{_sysconfdir}/cron.daily/greylist-tidy.sh
481 484 
482%changelog485%changelog
486+* Thu Oct 17 2024 changtao <changtao@kylinos.cn> - 4.97.1-3
487+- fix CVE-2024-39929
488+ 
483* Tue Jul 9 2024 technology208 <technology@208suo.com> - 4.97-2489* Tue Jul 9 2024 technology208 <technology@208suo.com> - 4.97-2
484- Fix CVE-2023-51766490- Fix CVE-2023-51766
485 491 
@@ -492,7 +498,7 @@ fi
492* Tue Aug 29 2023 zhuchao <tom_toworld@163.com> - 4.96-3498* Tue Aug 29 2023 zhuchao <tom_toworld@163.com> - 4.96-3
493- DESC:fix bug about print error message in install exim-clamav and exim-greylist499- DESC:fix bug about print error message in install exim-clamav and exim-greylist
494 500 
495-* Thur Feb 16 2023 zhuchao <tom_toworld@163.com> - 4.96-2501+* Thu Feb 16 2023 zhuchao <tom_toworld@163.com> - 4.96-2
496- DESC:add build requirement init502- DESC:add build requirement init
497 503 
498* Tue Oct 18 2022 zhuchao <tom_toworld@163.com> - 4.96-1504* Tue Oct 18 2022 zhuchao <tom_toworld@163.com> - 4.96-1