Prereq: "3.5.12" diff -ur --new-file /var/tmp/postfix-3.5.12/src/global/mail_version.h ./src/global/mail_version.h --- /var/tmp/postfix-3.5.12/src/global/mail_version.h 2021-07-24 19:19:08.000000000 -0400 +++ ./src/global/mail_version.h 2021-11-07 17:35:31.000000000 -0500 @@ -20,8 +20,8 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20210724" -#define MAIL_VERSION_NUMBER "3.5.12" +#define MAIL_RELEASE_DATE "20211107" +#define MAIL_VERSION_NUMBER "3.5.13" #ifdef SNAPSHOT #define MAIL_VERSION_DATE "-" MAIL_RELEASE_DATE diff -ur --new-file /var/tmp/postfix-3.5.12/HISTORY ./HISTORY --- /var/tmp/postfix-3.5.12/HISTORY 2021-07-24 18:42:14.000000000 -0400 +++ ./HISTORY 2021-11-07 18:09:38.000000000 -0500 @@ -24987,3 +24987,71 @@ was comparing memory addresses instead of queue file names. It now properly compares strings. Reported by Mehmet Avcioglu. File: global/record.c. + +20210811 + + Bitrot: OpenSSL 3.x requires const. File: tls/tls_misc.c. + +20210925 + + Bugfix (bug introduced: Postfix 2.10): postconf -x produced + incorrect output, because different functions were implicitly + sharing a buffer for intermediate results. Reported + by raf, root cause analysis by Viktor Dukhovni. File: + postconf/postconf_builtin.c. + +20211030 + + Bugfix (problem introduced: Postfix 2.11): check_ccert_access + worked as expected, but produced a spurious warning when + Postfix was built without SASL support. Fix by Brad Barden. + File: smtpd/smtpd_check.c. + +20211105 + + Bugfix (introduced: Postfix 2.4): queue file corruption + after a Milter (for example, MIMEDefang) made a request to + replace the message body with a copy of that message body + plus additional text (for example, a SpamAssassin report). + + The most likely impacts were a) the queue manager reporting + a fatal error resulting in email delivery delays, or b) the + queue manager reporting the corruption and moving the message + to the corrupt queue for damaged messages. + + However, a determined adversary could craft an email message + that would trigger the bug, and insert a content filter + destination or a redirect email address into its queue file. + Postfix would then deliver the message headers there, in + most cases without delivering the message body. With enough + experimentation, an attacker could make Postfix deliver + both the message headers and body. + + The details of a successful attack depend on the Milter + implementation, and on the Postfix and Milter configuration + details; these can be determined remotely through + experimentation. Failed experiments may be detected when + the queue manager terminates with a fatal error, or when + the queue manager moves damaged files to the "corrupt" queue + as evidence. + + Technical details: when Postfix executes a "replace body" + Milter request it will reuse queue file storage that was + used by the existing email message body. If the new body + is larger, Postfix will append body content to the end of + the queue file. The corruption happened when a Milter (for + example, MIMEDefang) made a request to replace the body of + a message with a new body that contained a copy of the + original body plus some new text, and the original body + contained a line longer than $line_length_limit bytes (for + example, an image encoded in base64 without hard or soft + line breaks). In queue files, Postfix stores a long text + line as multiple records with up to $line_length_limit bytes + each. Unfortunately, Postfix's "replace body" support did + not account for the additional queue file space needed to + store the second etc. record headers. And thus, the last + record(s) of a long text line could overwrite one or more + queue file records immediately after the space that was + previously occupied by the original message body. + + Problem report by BenoƮt Panizzon. diff -ur --new-file /var/tmp/postfix-3.5.12/src/cleanup/cleanup_body_edit.c ./src/cleanup/cleanup_body_edit.c --- /var/tmp/postfix-3.5.12/src/cleanup/cleanup_body_edit.c 2017-12-27 17:29:44.000000000 -0500 +++ ./src/cleanup/cleanup_body_edit.c 2021-11-05 18:39:27.000000000 -0400 @@ -207,7 +207,7 @@ /* * Finally, output the queue file record. */ - CLEANUP_OUT_BUF(state, REC_TYPE_NORM, buf); + CLEANUP_OUT_BUF(state, rec_type, buf); curr_rp->write_offs = vstream_ftell(state->dst); return (0); diff -ur --new-file /var/tmp/postfix-3.5.12/src/cleanup/cleanup_milter.c ./src/cleanup/cleanup_milter.c --- /var/tmp/postfix-3.5.12/src/cleanup/cleanup_milter.c 2020-11-04 16:06:12.000000000 -0500 +++ ./src/cleanup/cleanup_milter.c 2021-11-05 18:39:27.000000000 -0400 @@ -1834,7 +1834,8 @@ /* cleanup_repl_body - replace message body */ -static const char *cleanup_repl_body(void *context, int cmd, VSTRING *buf) +static const char *cleanup_repl_body(void *context, int cmd, int rec_type, + VSTRING *buf) { const char *myname = "cleanup_repl_body"; CLEANUP_STATE *state = (CLEANUP_STATE *) context; @@ -1846,7 +1847,7 @@ */ switch (cmd) { case MILTER_BODY_LINE: - if (cleanup_body_edit_write(state, REC_TYPE_NORM, buf) < 0) + if (cleanup_body_edit_write(state, rec_type, buf) < 0) return (cleanup_milter_error(state, errno)); break; case MILTER_BODY_START: diff -ur --new-file /var/tmp/postfix-3.5.12/src/milter/milter.h ./src/milter/milter.h --- /var/tmp/postfix-3.5.12/src/milter/milter.h 2020-02-02 15:49:15.000000000 -0500 +++ ./src/milter/milter.h 2021-11-05 18:39:27.000000000 -0400 @@ -100,7 +100,7 @@ typedef const char *(*MILTER_EDIT_FROM_FN) (void *, const char *, const char *); typedef const char *(*MILTER_EDIT_RCPT_FN) (void *, const char *); typedef const char *(*MILTER_EDIT_RCPT_PAR_FN) (void *, const char *, const char *); -typedef const char *(*MILTER_EDIT_BODY_FN) (void *, int, VSTRING *); +typedef const char *(*MILTER_EDIT_BODY_FN) (void *, int, int, VSTRING *); typedef struct MILTERS { MILTER *milter_list; /* linked list of Milters */ diff -ur --new-file /var/tmp/postfix-3.5.12/src/milter/milter8.c ./src/milter/milter8.c --- /var/tmp/postfix-3.5.12/src/milter/milter8.c 2020-02-02 15:49:15.000000000 -0500 +++ ./src/milter/milter8.c 2021-11-05 18:39:27.000000000 -0400 @@ -1147,10 +1147,12 @@ if (edit_resp == 0 && LEN(body_line_buf) > 0) edit_resp = parent->repl_body(parent->chg_context, MILTER_BODY_LINE, + REC_TYPE_NORM, body_line_buf); if (edit_resp == 0) edit_resp = parent->repl_body(parent->chg_context, MILTER_BODY_END, + /* unused*/ 0, (VSTRING *) 0); body_edit_lockout = 1; vstring_free(body_line_buf); @@ -1546,6 +1548,7 @@ body_line_buf = vstring_alloc(var_line_limit); edit_resp = parent->repl_body(parent->chg_context, MILTER_BODY_START, + /* unused */ 0, (VSTRING *) 0); } /* Extract lines from the on-the-wire CRLF format. */ @@ -1559,9 +1562,18 @@ LEN(body_line_buf) - 1); edit_resp = parent->repl_body(parent->chg_context, MILTER_BODY_LINE, + REC_TYPE_NORM, body_line_buf); VSTRING_RESET(body_line_buf); } else { + /* Preserves \r if not followed by \n. */ + if (LEN(body_line_buf) == var_line_limit) { + edit_resp = parent->repl_body(parent->chg_context, + MILTER_BODY_LINE, + REC_TYPE_CONT, + body_line_buf); + VSTRING_RESET(body_line_buf); + } VSTRING_ADDCH(body_line_buf, ch); } } diff -ur --new-file /var/tmp/postfix-3.5.12/src/postconf/postconf_builtin.c ./src/postconf/postconf_builtin.c --- /var/tmp/postfix-3.5.12/src/postconf/postconf_builtin.c 2018-01-14 20:30:12.000000000 -0500 +++ ./src/postconf/postconf_builtin.c 2021-09-25 19:01:43.000000000 -0400 @@ -244,6 +244,7 @@ static const char *pcf_mynetworks(void) { static const char *networks; + VSTRING *exp_buf; const char *junk; /* @@ -252,10 +253,12 @@ if (networks) return (networks); + exp_buf = vstring_alloc(100); + if (var_inet_interfaces == 0) { if ((pcf_cmd_mode & PCF_SHOW_DEFS) || (junk = mail_conf_lookup_eval(VAR_INET_INTERFACES)) == 0) - junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode, + junk = pcf_expand_parameter_value(exp_buf, pcf_cmd_mode, DEF_INET_INTERFACES, (PCF_MASTER_ENT *) 0); var_inet_interfaces = mystrdup(junk); @@ -263,7 +266,7 @@ if (var_mynetworks_style == 0) { if ((pcf_cmd_mode & PCF_SHOW_DEFS) || (junk = mail_conf_lookup_eval(VAR_MYNETWORKS_STYLE)) == 0) - junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode, + junk = pcf_expand_parameter_value(exp_buf, pcf_cmd_mode, DEF_MYNETWORKS_STYLE, (PCF_MASTER_ENT *) 0); var_mynetworks_style = mystrdup(junk); @@ -271,12 +274,13 @@ if (var_inet_protocols == 0) { if ((pcf_cmd_mode & PCF_SHOW_DEFS) || (junk = mail_conf_lookup_eval(VAR_INET_PROTOCOLS)) == 0) - junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode, + junk = pcf_expand_parameter_value(exp_buf, pcf_cmd_mode, DEF_INET_PROTOCOLS, (PCF_MASTER_ENT *) 0); var_inet_protocols = mystrdup(junk); (void) inet_proto_init(VAR_INET_PROTOCOLS, var_inet_protocols); } + vstring_free(exp_buf); return (networks = mystrdup(mynetworks())); } diff -ur --new-file /var/tmp/postfix-3.5.12/src/smtpd/smtpd_check.c ./src/smtpd/smtpd_check.c --- /var/tmp/postfix-3.5.12/src/smtpd/smtpd_check.c 2020-05-05 18:33:34.000000000 -0400 +++ ./src/smtpd/smtpd_check.c 2021-11-06 19:44:46.000000000 -0400 @@ -4338,8 +4338,8 @@ } } else if (is_map_command(state, name, CHECK_CCERT_ACL, &cpp)) { status = check_ccert_access(state, *cpp, def_acl); -#ifdef USE_SASL_AUTH } else if (is_map_command(state, name, CHECK_SASL_ACL, &cpp)) { +#ifdef USE_SASL_AUTH if (var_smtpd_sasl_enable) { if (state->sasl_username && state->sasl_username[0]) status = check_sasl_access(state, *cpp, def_acl); diff -ur --new-file /var/tmp/postfix-3.5.12/src/tls/tls_misc.c ./src/tls/tls_misc.c --- /var/tmp/postfix-3.5.12/src/tls/tls_misc.c 2020-07-26 13:03:13.000000000 -0400 +++ ./src/tls/tls_misc.c 2021-08-11 15:10:00.000000000 -0400 @@ -838,7 +838,7 @@ EVP_PKEY *pkey = 0; #ifndef OPENSSL_NO_EC - EC_KEY *eckey; + const EC_KEY *eckey; #endif