From: Wietse Venema Date: Tue, 25 Jul 2006 05:00:00 +0000 (-0500) Subject: postfix-2.4-20060725 X-Git-Tag: v2.4.0-RC1~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=315b0f33cabd1143cb1ae9303c32b667529d3638;p=thirdparty%2Fpostfix.git postfix-2.4-20060725 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 2d849cfa1..64c2bef1e 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -12612,6 +12612,16 @@ Apologies for any names omitted. Postfix Milter client created a queue file that caused delivery agents to loop. File: cleanup/cleanup_milter.c. +20060725 + + Bugfix: damaged queue file record after a Milter request + to modify a message header when 1) it was the last header + in the unmodified message, and 2) the old header was less + than 15 characters long. File: cleanup/cleanup_milter.c. + + Bugfix: don't panic in smtp_rcpt_cleanup() after detecting + a damaged queue file record. File: smtp/smtp_proto.c. + Wish list: Add M flag (enable multi-recipient delivery) to pipe daemon. diff --git a/postfix/src/cleanup/Makefile.in b/postfix/src/cleanup/Makefile.in index 958057df7..ed3f100b7 100644 --- a/postfix/src/cleanup/Makefile.in +++ b/postfix/src/cleanup/Makefile.in @@ -65,7 +65,7 @@ cleanup_milter: cleanup_milter.o $(CLEANUP_MILTER_OBJS) $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(CLEANUP_MILTER_OBJS) $(LIBS) $(SYSLIBS) mv junk cleanup_milter.o -tests: cleanup_masquerade_test cleanup_milter_test +tests: cleanup_masquerade_test cleanup_milter_test cleanup_milter_test2 root_tests: @@ -93,6 +93,15 @@ cleanup_milter_test: cleanup_milter cleanup_milter.in1 cleanup_milter.ref1 \ diff cleanup_milter.ref1 cleanup_milter.tmp rm -f test-queue-file.tmp cleanup_milter.tmp +cleanup_milter_test2: cleanup_milter cleanup_milter.in2 cleanup_milter.ref2 \ + test-queue-file2 ../postcat/postcat + cp test-queue-file2 test-queue-file2.tmp + chmod u+w test-queue-file2.tmp + ./cleanup_milter /dev/null >cleanup_milter.tmp + diff cleanup_milter.ref2 cleanup_milter.tmp + rm -f test-queue-file2.tmp cleanup_milter.tmp + depend: $(MAKES) (sed '1,/^# do not edit/!d' Makefile.in; \ set -e; for i in [a-z][a-z0-9]*.c; do \ diff --git a/postfix/src/cleanup/cleanup_milter.c b/postfix/src/cleanup/cleanup_milter.c index 15052e3b7..5cab391d7 100644 --- a/postfix/src/cleanup/cleanup_milter.c +++ b/postfix/src/cleanup/cleanup_milter.c @@ -623,7 +623,12 @@ static const char *cleanup_patch_header(CLEANUP_STATE *state, msg_warn("%s: seek file %s: %m", myname, cleanup_path); CLEANUP_PATCH_HEADER_RETURN(cleanup_milter_error(state, errno)); } - CLEANUP_OUT_BUF(state, rec_type, buf); + /* The saved "append header" pointer record may still contain "0". */ + if (saved_read_offset == state->append_hdr_pt_offset) + cleanup_out_format(state, REC_TYPE_PTR, REC_TYPE_PTR_FORMAT, + (long) state->append_hdr_pt_target); + else + CLEANUP_OUT_BUF(state, rec_type, buf); if (msg_verbose > 1) msg_info("%s: %ld: write %.*s", myname, (long) write_offset, LEN(buf) > 30 ? 30 : (int) LEN(buf), STR(buf)); @@ -825,6 +830,9 @@ static const char *cleanup_upd_header(void *context, ssize_t index, CLEANUP_UPD_HEADER_RETURN(cleanup_milter_error(state, errno)); } if (rec_type == REC_TYPE_PTR) { + /* The "append header" pointer record content must be saved. */ + if (saved_read_offset == state->append_hdr_pt_offset) + break; if (jumped == 0) { /* Enough contiguous space for writing a PTR record. */ avail_space += read_offset - saved_read_offset; diff --git a/postfix/src/cleanup/cleanup_milter.in2 b/postfix/src/cleanup/cleanup_milter.in2 new file mode 100644 index 000000000..5bdbdc522 --- /dev/null +++ b/postfix/src/cleanup/cleanup_milter.in2 @@ -0,0 +1,10 @@ +#verbose on +open test-queue-file2.tmp +upd_header 1 Subject hey! +upd_header 1 Subject hey! +upd_header 1 Subject hey! +add_header foo foobar +upd_header 1 foo foobar +upd_header 1 foo foobar +upd_header 1 foo foobar +close diff --git a/postfix/src/cleanup/cleanup_milter.ref2 b/postfix/src/cleanup/cleanup_milter.ref2 new file mode 100644 index 000000000..1d3fdc531 --- /dev/null +++ b/postfix/src/cleanup/cleanup_milter.ref2 @@ -0,0 +1,32 @@ +*** ENVELOPE RECORDS test-queue-file2.tmp *** + 0 message_size: 329 181 1 0 + 65 message_arrival_time: Tue Jul 25 15:37:06 2006 + 82 create_time: Tue Jul 25 15:37:06 2006 + 106 named_attribute: rewrite_context=local + 129 sender_fullname: Wietse Venema + 144 sender: me@porcupine.org + 162 pointer_record: 0 + 179 *** MESSAGE CONTENTS test-queue-file2.tmp *** + 181 regular_text: Received: by bristle.watson.ibm.com (Postfix, from userid 0) + 243 regular_text: id 034B229013F; Tue, 25 Jul 2006 15:37:06 -0400 (EDT) + 299 regular_text: From: me@porcupine.org + 323 regular_text: To: you@porcupine.org + 346 regular_text: Message-Id: <20060725192735.5EC2D29013F@hades.porcupine.org> + 408 regular_text: Date: Tue, 25 Jul 2006 15:27:19 -0400 (EDT) + 453 pointer_record: 552 + 552 pointer_record: 584 + 584 pointer_record: 616 + 616 regular_text: Subject: hey! + 631 pointer_record: 648 + 648 pointer_record: 678 + 678 pointer_record: 708 + 708 pointer_record: 738 + 738 regular_text: foo: foobar + 751 pointer_record: 485 + 485 regular_text: + 487 regular_text: text + 493 pointer_record: 0 + 510 *** HEADER EXTRACTED test-queue-file2.tmp *** + 512 original_recipient: you@porcupine.org + 531 recipient: you@porcupine.org + 550 *** MESSAGE FILE END test-queue-file2.tmp *** diff --git a/postfix/src/cleanup/test-queue-file2 b/postfix/src/cleanup/test-queue-file2 new file mode 100644 index 000000000..f5a7b0194 Binary files /dev/null and b/postfix/src/cleanup/test-queue-file2 differ diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 51265c66e..033693439 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20060724" +#define MAIL_RELEASE_DATE "20060725" #define MAIL_VERSION_NUMBER "2.4" #ifdef SNAPSHOT diff --git a/postfix/src/smtp/smtp_proto.c b/postfix/src/smtp/smtp_proto.c index 7fb0c262f..a7c865845 100644 --- a/postfix/src/smtp/smtp_proto.c +++ b/postfix/src/smtp/smtp_proto.c @@ -987,6 +987,8 @@ static int smtp_loop(SMTP_STATE *state, NOCLOBBER int send_state, NOCLOBBER int mail_from_rejected; NOCLOBBER int downgrading; int mime_errs; + SMTP_RESP fake; + int fail_status; /* * Macros for readability. @@ -1696,7 +1698,12 @@ static int smtp_loop(SMTP_STATE *state, NOCLOBBER int send_state, if (rec_type != REC_TYPE_XTRA) { msg_warn("%s: bad record type: %d in message content", request->queue_id, rec_type); - RETURN(mark_corrupt(state->src)); + fail_status = smtp_mesg_fail(state, DSN_BY_LOCAL_MTA, + SMTP_RESP_FAKE(&fake, "5.3.0"), + "unreadable mail queue entry"); + if (fail_status == 0) + (void) mark_corrupt(state->src); + RETURN(fail_status); } }