]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-3.6.3 v3.6.3
authorWietse Venema <wietse@porcupine.org>
Sun, 7 Nov 2021 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <postfix-users@dukhovni.org>
Mon, 8 Nov 2021 13:51:20 +0000 (08:51 -0500)
16 files changed:
postfix/HISTORY
postfix/src/cleanup/cleanup_body_edit.c
postfix/src/cleanup/cleanup_milter.c
postfix/src/global/config_known_tcp_ports.c
postfix/src/global/mail_params.c
postfix/src/global/mail_version.h
postfix/src/milter/milter.h
postfix/src/milter/milter8.c
postfix/src/postconf/postconf_builtin.c
postfix/src/posttls-finger/posttls-finger.c
postfix/src/smtp/smtp_connect.c
postfix/src/smtpd/smtpd_check.c
postfix/src/tls/tls_dane.c
postfix/src/tls/tls_misc.c
postfix/src/util/find_inet.c
postfix/src/util/myaddrinfo.c

index e6db218a93c3ece947e9231b673e6d451ae64168..538f86001fd0c4aad4c1c7a258d583159275c27a 100644 (file)
@@ -25612,3 +25612,85 @@ Apologies for any names omitted.
        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.
+
+20211022
+
+       Bugfix (introduced: Postfix 3.6): the known_tcp_ports setting
+       had no effect. Reported by Peter. The feature wasn't fully
+       implemented. Files: config_known_tcp_ports.c, mail_params.c,
+       posttls-finger/posttls-finger.c, smtp/smtp_connect.c,
+       util/find_inet.c, util/myaddrinfo.c.
+
+20211025
+
+       Bugfix (introduced: Postfix 3.6): mangled warning where a
+       hostname and warning message run together. Viktor Dukhovni.
+       File: tls/tls_dane.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.
index 93eadae0b82542d36491ff4c8254b1d4ea6f7732..2fff1bcadd4788a92ce4c81daac3d37a6b35be90 100644 (file)
@@ -207,7 +207,7 @@ int     cleanup_body_edit_write(CLEANUP_STATE *state, int rec_type,
     /*
      * 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);
index 556a508950a6b1b60a2990e3bbce9fd100d9a9f8..d176af1394a00e7acc111d21113050cb3f47608a 100644 (file)
@@ -1836,7 +1836,8 @@ static const char *cleanup_del_rcpt(void *context, const char *ext_rcpt)
 
 /* 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;
@@ -1848,7 +1849,7 @@ static const char *cleanup_repl_body(void *context, int cmd, VSTRING *buf)
      */
     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:
index 84f66e81032c2f6a0ca032cd4e2f48a57f798640..563bbd356d4cdc7cccf9e5514e4a1d29c269c5fd 100644 (file)
@@ -58,6 +58,8 @@ void    config_known_tcp_ports(const char *source, const char *settings)
     ARGV   *association;
     char  **cpp;
 
+    clear_known_tcp_ports();
+
     /*
      * The settings is in the form of associations separated by comma. Split
      * it into separate associations.
index 44a5a84ac9f4846d0b43e3a160edb1d011b83b31..81aee73cfcf8ba901f638f891f5c863ba110d99e 100644 (file)
 #include <own_inet_addr.h>
 #include <mail_params.h>
 #include <compat_level.h>
+#include <config_known_tcp_ports.h>
 
  /*
   * Special configuration variables.
@@ -922,6 +923,11 @@ void    mail_params_init()
 #endif
     util_utf8_enable = var_smtputf8_enable;
 
+    /*
+     * Configure the known TCP port mappings.
+     */
+    config_known_tcp_ports(VAR_KNOWN_TCP_PORTS, var_known_tcp_ports);
+
     /*
      * What protocols should we attempt to support? The result is stored in
      * the global inet_proto_table variable.
index 4304de047da5b2717f75951dc05911d48de3b190..099c17c901807d534b13ccb02d525748ba592886 100644 (file)
@@ -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.6.2"
+#define MAIL_RELEASE_DATE      "20211107"
+#define MAIL_VERSION_NUMBER    "3.6.3"
 
 #ifdef SNAPSHOT
 #define MAIL_VERSION_DATE      "-" MAIL_RELEASE_DATE
index 8f672c30441b3f0329b9928c8bbc1b41b2d7b295..744d679abf678777bcd549a095a753240a0532df 100644 (file)
@@ -100,7 +100,7 @@ typedef const char *(*MILTER_DEL_HEADER_FN) (void *, ssize_t, const char *);
 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 */
index 892c38721e20bce073c5c5bfdd07bad9c5c621aa..634473412ded112bc0578b2ae38baf2dd5c862dd 100644 (file)
@@ -1147,10 +1147,12 @@ static const char *milter8_event(MILTER8 *milter, int event,
            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 @@ static const char *milter8_event(MILTER8 *milter, int event,
                        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 @@ static const char *milter8_event(MILTER8 *milter, int event,
                                                 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);
                        }
                    }
index c489053875e8211d121e38258851447d9be7bd39..471b8cfdca1c3322f1f4232a3c5eebe43f5b68bd 100644 (file)
@@ -247,6 +247,7 @@ static const char *pcf_check_mydomainname(void)
 static const char *pcf_mynetworks(void)
 {
     static const char *networks;
+    VSTRING *exp_buf;
     const char *junk;
 
     /*
@@ -255,10 +256,12 @@ static const char *pcf_mynetworks(void)
     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);
@@ -266,7 +269,7 @@ static const char *pcf_mynetworks(void)
     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);
@@ -274,12 +277,13 @@ static const char *pcf_mynetworks(void)
     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()));
 }
 
index 252db401f7b7dc5dda885028153b7c6fa0a6de47..2a496168ca59f4e72bc4d6e8d8a5453b51e09669 100644 (file)
@@ -1488,12 +1488,14 @@ static char *parse_destination(char *destination, char *def_service,
     /*
      * Convert service to port number, network byte order.
      */
+    service = (char *) filter_known_tcp_port(service);
     if (alldig(service)) {
        if ((port = atoi(service)) >= 65536 || port == 0)
-           msg_fatal("bad network port in destination: %s", destination);
+           msg_fatal("bad network port: %s for destination: %s",
+                     service, destination);
        *portp = htons(port);
     } else {
-       if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) != 0)
+       if ((sp = getservbyname(service, protocol)) != 0)
            *portp = sp->s_port;
        else if (strcmp(service, "smtp") == 0)
            *portp = htons(25);
index 43df3fe04a52c2520ed6c950a48eed1edf77eda8..f93e7efc64480e8da8465cde64b93da965badaad 100644 (file)
@@ -356,12 +356,14 @@ static char *smtp_parse_destination(char *destination, char *def_service,
     /*
      * Convert service to port number, network byte order.
      */
+    service = (char *) filter_known_tcp_port(service);
     if (alldig(service)) {
        if ((port = atoi(service)) >= 65536 || port == 0)
-           msg_fatal("bad network port in destination: %s", destination);
+           msg_fatal("bad network port: %s for destination: %s",
+                     service, destination);
        *portp = htons(port);
     } else {
-       if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) == 0)
+       if ((sp = getservbyname(service, protocol)) == 0)
            msg_fatal("unknown service: %s/%s", service, protocol);
        *portp = sp->s_port;
     }
index 1a2d558ab53f3a2f4a485be551c4d40e92437519..5bbee93b24d745f38f380b2560d303435ce3d412 100644 (file)
@@ -4374,8 +4374,8 @@ static int generic_checks(SMTPD_STATE *state, ARGV *restrictions,
            }
        } 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);
index a31a513742201806aa1ca868fa2e58774c7bc22a..752bb5b1c2f7a564e0f452c516ef941e6d53a3d3 100644 (file)
@@ -392,7 +392,7 @@ static void tlsa_carp(const char *s1, const char *s2, const char *s3,
        vstring_sprintf(top, "...");
     }
 
-    msg_warn("%s%s%s%s: %u %u %u %s%s%s", s1, s2, s3, s4, u, s, m, STR(top),
+    msg_warn("%s%s%s %s: %u %u %u %s%s%s", s1, s2, s3, s4, u, s, m, STR(top),
             dlen > MAX_DUMP_BYTES ? "..." : "",
             dlen > MAX_DUMP_BYTES ? STR(bot) : "");
 }
@@ -807,13 +807,13 @@ int     tls_dane_enable(TLS_SESS_STATE *TLScontext)
            continue;
        }
        if (ret == 0) {
-           tlsa_carp(TLScontext->namaddr, ": ", "", "unusable TLSA RR",
+           tlsa_carp(TLScontext->namaddr, ":", "", "unusable TLSA RR",
                      tp->usage, tp->selector, tp->mtype, tp->data,
                      tp->length);
            continue;
        }
        /* Internal problem in OpenSSL */
-       tlsa_carp(TLScontext->namaddr, ": ", "", "error loading trust settings",
+       tlsa_carp(TLScontext->namaddr, ":", "", "error loading trust settings",
                  tp->usage, tp->selector, tp->mtype, tp->data, tp->length);
        tls_print_errors();
        return (-1);
index 55af34d3cb3d834080652fab2f4feb45f3219cc3..29a7e6eef504bcfafcdc80819945ef6aebb949d2 100644 (file)
@@ -883,7 +883,7 @@ void    tls_get_signature_params(TLS_SESS_STATE *TLScontext)
     EVP_PKEY *peer_pkey = 0;
 
 #ifndef OPENSSL_NO_EC
-    EC_KEY *eckey;
+    const EC_KEY *eckey;
 
 #endif
 
index 47a5cff4e1842d79532fe56950db341be20abbc2..14efe63dc1e72121459b9354cf1d6d3f19fc56d9 100644 (file)
@@ -85,12 +85,13 @@ int     find_inet_port(const char *service, const char *protocol)
     struct servent *sp;
     int     port;
 
+    service = filter_known_tcp_port(service);
     if (alldig(service) && (port = atoi(service)) != 0) {
        if (port < 0 || port > 65535)
            msg_fatal("bad port number: %s", service);
        return (htons(port));
     } else {
-       if ((sp = getservbyname(filter_known_tcp_port(service), protocol)) == 0)
+       if ((sp = getservbyname(service, protocol)) == 0)
            msg_fatal("unknown service: %s/%s", service, protocol);
        return (sp->s_port);
     }
index ec62676e1db56d8e8d27fea47447bb0dfd7de5da..cb474caf272090a23d2c85c8afb3e016a45a5c1c 100644 (file)
@@ -271,6 +271,7 @@ static int find_service(const char *service, int socktype)
     const char *proto;
     unsigned port;
 
+    service = filter_known_tcp_port(service);
     if (alldig(service)) {
        port = atoi(service);
        return (port < 65536 ? htons(port) : -1);
@@ -282,7 +283,7 @@ static int find_service(const char *service, int socktype)
     } else {
        return (-1);
     }
-    if ((sp = getservbyname(filter_known_tcp_port(service), proto)) != 0) {
+    if ((sp = getservbyname(service, proto)) != 0) {
        return (sp->s_port);
     } else {
        return (-1);
@@ -445,7 +446,12 @@ int     hostname_to_sockaddr_pf(const char *hostname, int pf,
        }
 #endif
     }
-    err = getaddrinfo(hostname, filter_known_tcp_port(service), &hints, res);
+    if (service) {
+       service = filter_known_tcp_port(service);
+       if (alldig(service))
+           hints.ai_flags |= AI_NUMERICSERV;
+    }
+    err = getaddrinfo(hostname, service, &hints, res);
 #if defined(BROKEN_AI_NULL_SERVICE)
     if (service == 0 && err == 0) {
        struct addrinfo *r;
@@ -561,7 +567,12 @@ int     hostaddr_to_sockaddr(const char *hostaddr, const char *service,
        }
 #endif
     }
-    err = getaddrinfo(hostaddr, filter_known_tcp_port(service), &hints, res);
+    if (service) {
+       service = filter_known_tcp_port(service);
+       if (alldig(service))
+           hints.ai_flags |= AI_NUMERICSERV;
+    }
+    err = getaddrinfo(hostaddr, service, &hints, res);
 #if defined(BROKEN_AI_NULL_SERVICE)
     if (service == 0 && err == 0) {
        struct addrinfo *r;