Subject: pkg/36709: milter bug in mail/postfix (patch supplied)
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <j+nbsd@2007.salmi.ch>
List: pkgsrc-bugs
Date: 07/31/2007 09:25:01
Note: There was a bad value `' for the field `Priority'.
It was set to the default value of `medium'.
>Number: 36709
>Category: pkg
>Synopsis: milter bug in mail/postfix (patch supplied)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 31 09:25:00 +0000 2007
>Originator: Jukka Salmi
>Release: NetBSD 4.99.25
>Environment:
pkgsrc HEAD and pkgsrc-2007Q2
>Description:
Recently a milter bug in Postfix was fixed. This PR applies supplies
that fix for pkgsrc.
>How-To-Repeat:
See
http://marc.info/?l=postfix-users&m=118572453228610&w=2
http://marc.info/?l=postfix-users&m=118581685316159&w=2
http://marc.info/?l=postfix-users&m=118584367216561&w=2
>Fix:
Apply the attached patch which is also available from
http://salmi.ch/~jukka/patches/pkgsrc/mail/postfix/milter.patch
Index: mail/postfix/distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/mail/postfix/distinfo,v
retrieving revision 1.112
diff -u -p -r1.112 distinfo
--- mail/postfix/distinfo 1 Jun 2007 03:34:07 -0000 1.112
+++ mail/postfix/distinfo 31 Jul 2007 08:54:59 -0000
@@ -4,5 +4,10 @@ SHA1 (postfix/postfix-2.4.3.tar.gz) = 7d
RMD160 (postfix/postfix-2.4.3.tar.gz) = cf07bdabf1c468daaebc164cb8b048130f42ab4b
Size (postfix/postfix-2.4.3.tar.gz) = 2929905 bytes
SHA1 (patch-aa) = b8f4e67ac18dcd1e5e3c56ad587b4552c539caa0
+SHA1 (patch-ab) = ad8940847c83bd8092e628b52a916e601f3d3e9f
+SHA1 (patch-ac) = f91f8ff368ef3832a606b6c00267151122284fb9
+SHA1 (patch-ad) = 9def550d698bf8f745f88278c93615a0de68fc05
+SHA1 (patch-ae) = dd46e2d5980a1422d9967980b704bbbd5c47c2ba
+SHA1 (patch-af) = 9332aaca86ae3567342a0a9c83826b051a11a26e
SHA1 (patch-ag) = 4d66026fe81dde97470bd01d529af191f1547228
SHA1 (patch-ai) = 68201eac6b479ad733ba851741cc1cc2e56f7c9f
--- /dev/null 2007-07-31 10:52:50.000000000 +0200
+++ mail/postfix/patches/patch-ab 2007-07-31 10:51:00.000000000 +0200
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- src/cleanup/cleanup_envelope.c.orig 2007-01-16 20:08:07.000000000 +0100
++++ src/cleanup/cleanup_envelope.c 2007-07-31 10:17:30.000000000 +0200
+@@ -148,13 +148,7 @@ static void cleanup_envelope_process(CLE
+ #endif
+ if (type == REC_TYPE_MILT_COUNT) {
+ /* Not part of queue file format. */
+- if (state->milters != 0) {
+- msg_warn("%s: message rejected: too many milter instances",
+- state->queue_id);
+- state->errs |= CLEANUP_STAT_BAD;
+- return;
+- }
+- if ((milter_count = atoi(buf)) > 0)
++ if ((milter_count = atoi(buf)) >= 0)
+ cleanup_milter_receive(state, milter_count);
+ return;
+ }
--- /dev/null 2007-07-31 10:52:50.000000000 +0200
+++ mail/postfix/patches/patch-ac 2007-07-31 10:51:10.000000000 +0200
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/cleanup/cleanup_milter.c.orig 2007-01-22 14:45:33.000000000 +0100
++++ src/cleanup/cleanup_milter.c 2007-07-31 10:17:30.000000000 +0200
+@@ -1314,6 +1314,8 @@ static const char *cleanup_milter_eval(c
+
+ void cleanup_milter_receive(CLEANUP_STATE *state, int count)
+ {
++ if (state->milters)
++ milter_free(state->milters);
+ state->milters = milter_receive(state->src, count);
+ milter_macro_callback(state->milters, cleanup_milter_eval, (void *) state);
+ milter_edit_callback(state->milters,
--- /dev/null 2007-07-31 10:52:50.000000000 +0200
+++ mail/postfix/patches/patch-ad 2007-07-31 10:51:22.000000000 +0200
@@ -0,0 +1,61 @@
+$NetBSD$
+
+--- src/milter/milter.c.orig 2007-03-15 01:46:12.000000000 +0100
++++ src/milter/milter.c 2007-07-31 10:17:30.000000000 +0200
+@@ -97,6 +97,10 @@
+ /* MILTERS *milter_receive(fp, count)
+ /* VSTREAM *fp;
+ /* int count;
++/*
++/* int milter_dummy(milters, fp)
++/* MILTERS *milters;
++/* VSTREAM *fp;
+ /* DESCRIPTION
+ /* The functions in this module manage one or more milter (mail
+ /* filter) clients. Currently, only the Sendmail 8 filter
+@@ -192,6 +196,9 @@
+ /* milter_receive() receives the specified number of mail
+ /* filters over the specified stream. The result is a null
+ /* pointer when no milters were sent, or when an error happened.
++/*
++/* milter_dummy() is like milter_send(), except that it sends
++/* a dummy, but entirely valid, mail filter list.
+ /* SEE ALSO
+ /* milter8(3) Sendmail 8 Milter protocol
+ /* DIAGNOSTICS
+@@ -587,6 +594,16 @@ void milter_free(MILTERS *milters)
+ #define MAIL_ATTR_MILT_EOD "eod_macros"
+ #define MAIL_ATTR_MILT_UNK "unk_macros"
+
++/* milter_dummy - send empty milter list */
++
++int milter_dummy(MILTERS *milters, VSTREAM *stream)
++{
++ MILTERS dummy = *milters;
++
++ dummy.milter_list = 0;
++ return (milter_send(&dummy, stream));
++}
++
+ /* milter_send - send Milter instances over stream */
+
+ int milter_send(MILTERS *milters, VSTREAM *stream)
+@@ -606,8 +623,6 @@ int milter_send(MILTERS *milters, VS
+ for (m = milters->milter_list; m != 0; m = m->next)
+ if (m->active(m))
+ count++;
+- if (count == 0)
+- return (0);
+ (void) rec_fprintf(stream, REC_TYPE_MILT_COUNT, "%d", count);
+
+ /*
+@@ -656,9 +671,6 @@ MILTERS *milter_receive(VSTREAM *stream,
+ VSTRING *eod_macros;
+ VSTRING *unk_macros;
+
+- if (count == 0)
+- return (0);
+-
+ /*
+ * Receive filter macros.
+ */
--- /dev/null 2007-07-31 10:52:50.000000000 +0200
+++ mail/postfix/patches/patch-ae 2007-07-31 10:51:39.000000000 +0200
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- src/milter/milter.h.orig 2007-01-10 02:55:23.000000000 +0100
++++ src/milter/milter.h 2007-07-31 10:17:30.000000000 +0200
+@@ -99,6 +99,7 @@ extern const char *milter_unknown_event(
+ extern const char *milter_other_event(MILTERS *);
+ extern void milter_abort(MILTERS *);
+ extern void milter_disc_event(MILTERS *);
++extern int milter_dummy(MILTERS *, VSTREAM *);
+ extern int milter_send(MILTERS *, VSTREAM *);
+ extern MILTERS *milter_receive(VSTREAM *, int);
+ extern void milter_free(MILTERS *);
--- /dev/null 2007-07-31 10:52:50.000000000 +0200
+++ mail/postfix/patches/patch-af 2007-07-31 10:51:44.000000000 +0200
@@ -0,0 +1,25 @@
+$NetBSD$
+
+--- src/smtpd/smtpd.c.orig 2007-03-17 18:59:38.000000000 +0100
++++ src/smtpd/smtpd.c 2007-07-31 10:17:30.000000000 +0200
+@@ -1618,7 +1618,8 @@ static int mail_open_stream(SMTPD_STATE
+ if (SMTPD_STAND_ALONE(state) == 0) {
+ if (smtpd_milters != 0
+ && (state->saved_flags & MILTER_SKIP_FLAGS) == 0)
+- (void) milter_send(smtpd_milters, state->dest->stream);
++ /* Send place-holder smtpd_milters list. */
++ (void) milter_dummy(smtpd_milters, state->cleanup);
+ rec_fprintf(state->cleanup, REC_TYPE_TIME, REC_TYPE_TIME_FORMAT,
+ REC_TYPE_TIME_ARG(state->arrival_time));
+ if (*var_filter_xport)
+@@ -2521,6 +2522,10 @@ static int data_cmd(SMTPD_STATE *state,
+ */
+ if (state->cleanup) {
+ if (SMTPD_STAND_ALONE(state) == 0) {
++ if (smtpd_milters != 0
++ && (state->saved_flags & MILTER_SKIP_FLAGS) == 0)
++ /* Send actual smtpd_milters list. */
++ (void) milter_send(smtpd_milters, state->cleanup);
+ if (state->saved_flags)
+ rec_fprintf(state->cleanup, REC_TYPE_FLGS, "%d",
+ state->saved_flags);