~ubuntu-branches/ubuntu/trusty/postfix/trusty-updates

« back to all changes in this revision

Viewing changes to src/global/mime_state.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2007-01-31 12:45:49 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20070131124549-viz362ah0qjcygtj
Tags: 2.3.7-1
* New upstream version
  - Bugfix (introduced Postfix 2.3): when creating an alias map
    on a NIS-enabled system, don't case-fold the YP_MASTER_NAME
    and YP_LAST_MODIFIED lookup keys. This requires that an
    application can turn off case folding on the fly. This is
    a point fix. A complete fix requires updates to other map
    types and to the proxymap protocol, which is too much change
    for a stable release.
  - Bugfix (introduced 20011008): after return from a nested
    access restriction, possible longjump into exited stack
    frame upon configuration error or table lookup error.
  - Workaround: don't insert empty-line header/body separator
    into malformed MIME attachments, to avoid breaking digital
    signatures. This change introduces ambiguity. Postfix still
    treats the remainder of the attachment as body content;
    header_checks rules will not detect forbidden MIME types
    inside a message/rfc822 attachment.  With the empty-line
    header/body separator no longer inserted by Postfix, other
    software may process the malformed attachment differently,
    and thus may become exposed to forbidden MIME types.  This
    is back-ported from Postfix 2.4.
  - Bugfix: match lists didn't implement ![ipv6address].
* New fr.po
* Updated postfix_groups.pl.  Closes: #409009, #409010

Show diffs side-by-side

added added

removed removed

Lines of Context:
182
182
/* .IP state
183
183
/*      MIME parser state created with mime_state_alloc().
184
184
/* BUGS
 
185
/*      NOTE: when the end of headers is reached, mime_state_update()
 
186
/*      may execute up to three call-backs before returning to the
 
187
/*      caller: head_out(), head_end(), and body_out() or body_end().
 
188
/*      As long as call-backs return no result, it is up to the
 
189
/*      call-back routines to check if a previous call-back experienced
 
190
/*      an error.
 
191
/*
185
192
/*      Different mail user agents treat malformed message boundary
186
193
/*      strings in different ways. The Postfix MIME processor cannot
187
194
/*      be bug-compatible with everything.
492
499
 
493
500
    /* Volatile members. */
494
501
    state->err_flags = 0;
 
502
    state->body_offset = 0;                     /* XXX */
495
503
    SET_MIME_STATE(state, MIME_STATE_PRIMARY,
496
504
                   MIME_CTYPE_TEXT, MIME_STYPE_PLAIN,
497
505
                   MIME_ENC_7BIT, MIME_ENC_7BIT);
931
939
         * messages. Otherwise, treat such headers as part of the "body". Set
932
940
         * the proper encoding information for the multipart prolog.
933
941
         * 
 
942
         * XXX We parse headers inside message/* content even when the encoding
 
943
         * is invalid (encoding != domain). With base64 we won't recognize
 
944
         * any headers, and with quoted-printable we won't recognize MIME
 
945
         * boundary strings, but the MIME processor will still resynchronize
 
946
         * when it runs into the higher-level boundary string at the end of
 
947
         * the message/* content. Although we will treat some headers as body
 
948
         * text, we will still do a better job than if we were treating the
 
949
         * entire message/* content as body text.
 
950
         * 
934
951
         * XXX This changes state to MIME_STATE_NESTED and then outputs a body
935
952
         * line, so that the body offset is not properly reset.
936
953
         * 
959
976
            /*
960
977
             * Invalid input. Force output of one blank line and jump to the
961
978
             * body state, leaving all other state alone.
 
979
             * 
 
980
             * We don't break legitimate mail by inserting a blank line
 
981
             * separator between primary headers and a non-empty body. Many
 
982
             * MTA's don't even record the presence or absence of this
 
983
             * separator, nor does the Milter protocol pass it on to Milter
 
984
             * applications.
 
985
             * 
 
986
             * XXX We don't insert a blank line separator into attachments, to
 
987
             * avoid breaking digital signatures. Postfix shall not do a
 
988
             * worse mail delivery job than MTAs that can't even parse MIME.
 
989
             * We switch to body state anyway, to avoid treating body text as
 
990
             * header text, and mis-interpreting or truncating it. The code
 
991
             * below for initial From_ lines is for educational purposes.
 
992
             * 
 
993
             * Sites concerned about MIME evasion can use a MIME normalizer.
 
994
             * Postfix has a different mission.
962
995
             */
963
996
            else {
964
 
                SET_CURR_STATE(state, MIME_STATE_BODY);
965
 
                BODY_OUT(state, REC_TYPE_NORM, "", 0);
 
997
                if (msg_verbose)
 
998
                    msg_info("garbage in %s header",
 
999
                    state->curr_state == MIME_STATE_MULTIPART ? "multipart" :
 
1000
                       state->curr_state == MIME_STATE_PRIMARY ? "primary" :
 
1001
                         state->curr_state == MIME_STATE_NESTED ? "nested" :
 
1002
                             "other");
 
1003
                switch (state->curr_state) {
 
1004
                case MIME_STATE_PRIMARY:
 
1005
                    BODY_OUT(state, REC_TYPE_NORM, "", 0);
 
1006
                    SET_CURR_STATE(state, MIME_STATE_BODY);
 
1007
                    break;
 
1008
#if 0
 
1009
                case MIME_STATE_NESTED:
 
1010
                    if (state->body_offset <= 1
 
1011
                        && rec_type == REC_TYPE_NORM
 
1012
                        && len > 7
 
1013
                        && (strncmp(text + (*text == '>'), "From ", 5) == 0
 
1014
                            || strncmp(text, "=46rom ", 7) == 0))
 
1015
                        break;
 
1016
                    /* FALLTHROUGH */
 
1017
#endif
 
1018
                default:
 
1019
                    SET_CURR_STATE(state, MIME_STATE_BODY);
 
1020
                    break;
 
1021
                }
966
1022
            }
967
1023
        }
968
1024