Vladimir Vassiliev:
>
> Hi all,
>
> i'm trying to setup commercial spam filter with postfix. It works with
> Sendmail using milter
> protocol, but with Postfix I've got in logs:
>
> Aug 31 11:34:11 master postfix/cleanup[8458]: warning: milter
> inet:127.0.0.1:2266: malformed reply:
> 550 The message has been rejected by spam filtering engine.
>
> I've investigated problem to this place (src/milter/milter8.c):
> case SMFIR_REPLYCODE:
> ...
> if ((STR(milter->buf)[0] != '4' && STR(milter->buf)[0] != '5')
> || !ISDIGIT(STR(milter->buf)[1])
> || !ISDIGIT(STR(milter->buf)[2])
> || (STR(milter->buf)[3] != ' ' && STR(milter->buf)[3] != '-')
> || STR(milter->buf)[4] != STR(milter->buf)[0]) {
>
> Comment indicates that Postfix expects "ddd d.d+.d+ text", but anti-spam
> filter returns something
> different. So just removing last check resolves problem.
> Can someone confirm this fix doesn't break anything?
>
> Patch for version 2.7.4.
The test exists for a reason: it catches Milters that send RFC 3463
enhanced status codes that don't match the SMTP reply code.
Below is a quick fix that preserves the test for Milters that appear
to send enhanced status codes. This is OK for stable releases.
The proper solution examines every line of a multi-line reply.
That is a larger change, and is OK for the development release.
Wietse
*** src/milter/milter8.c- Thu Apr 28 10:09:30 2011
--- src/milter/milter8.c Wed Aug 31 09:04:19 2011
***************
*** 1255,1265 ****
MILTER8_DATA_BUFFER, milter->buf,
MILTER8_DATA_END) != 0)
MILTER8_EVENT_BREAK(milter->def_reply);
if ((STR(milter->buf)[0] != '4' && STR(milter->buf)[0] != '5')
|| !ISDIGIT(STR(milter->buf)[1])
|| !ISDIGIT(STR(milter->buf)[2])
|| (STR(milter->buf)[3] != ' ' && STR(milter->buf)[3] != '-')
! || STR(milter->buf)[4] != STR(milter->buf)[0]) {
msg_warn("milter %s: malformed reply: %s",
milter->m.name, STR(milter->buf));
milter8_conf_error(milter);
--- 1255,1267 ----
MILTER8_DATA_BUFFER, milter->buf,
MILTER8_DATA_END) != 0)
MILTER8_EVENT_BREAK(milter->def_reply);
+ /* XXX Enforce this for each line of a multi-line reply. */
if ((STR(milter->buf)[0] != '4' && STR(milter->buf)[0] != '5')
|| !ISDIGIT(STR(milter->buf)[1])
|| !ISDIGIT(STR(milter->buf)[2])
|| (STR(milter->buf)[3] != ' ' && STR(milter->buf)[3] != '-')
! || (ISDIGIT(STR(milter->buf)[4])
! && (STR(milter->buf)[4] != STR(milter->buf)[0]))) {
msg_warn("milter %s: malformed reply: %s",
milter->m.name, STR(milter->buf));
milter8_conf_error(milter);