From 8d1e60ee70008a0ab1cb15c602d090de435519f4 Mon Sep 17 00:00:00 2001 From: Wietse Z Venema Date: Mon, 18 Aug 2025 00:00:00 -0500 Subject: [PATCH] postfix-3.11-20250818 --- postfix/HISTORY | 7 +++++++ postfix/src/global/mail_version.h | 2 +- postfix/src/smtpd/smtpd.c | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/postfix/HISTORY b/postfix/HISTORY index 487698196..6a4f349d5 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -29568,3 +29568,10 @@ Apologies for any names omitted. documentation. This will be back-ported to Postfix 3.10. Files: Makefile.in, smtp/smtp.h smtp/smtp_connect.c, smtp/smtp_tls_policy.c, proto/postconf.proto. + +20250816 + + Bugfix (defect introduced: Postfix 3.0, date 20140731): the + smtpd 'disconnect' command counts did not count malformed + commands with "bad syntax" and "bad UTF-8 syntax" errors. + File: smtpd/smtpd.c. diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 35107f32b..1ea8819c7 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 "20250808" +#define MAIL_RELEASE_DATE "20250818" #define MAIL_VERSION_NUMBER "3.11" #ifdef SNAPSHOT diff --git a/postfix/src/smtpd/smtpd.c b/postfix/src/smtpd/smtpd.c index 3d3bc79ac..66a032eee 100644 --- a/postfix/src/smtpd/smtpd.c +++ b/postfix/src/smtpd/smtpd.c @@ -5639,6 +5639,13 @@ static SMTPD_CMD smtpd_cmd_table[] = { {0,}, }; + /* + * In addition to counting unknown commands, the last table element also + * counts malformed commands (which aren't looked up in the command table). + */ +#define LAST_TABLE_PTR(table) ((table) + sizeof(table)/sizeof(*(table)) - 1) +static SMTPD_CMD *smtpd_cmdp_unknown = LAST_TABLE_PTR(smtpd_cmd_table); + static STRING_LIST *smtpd_noop_cmds; static STRING_LIST *smtpd_forbid_cmds; @@ -6007,6 +6014,8 @@ static void smtpd_proto(SMTPD_STATE *state) state->error_mask |= MAIL_ERROR_PROTOCOL; smtpd_chat_reply(state, "500 5.5.2 Error: bad UTF-8 syntax"); state->error_count++; + state->where = SMTPD_CMD_UNKNOWN; + smtpd_cmdp_unknown->total_count += 1; continue; } /* Move into smtpd_chat_query() and update session transcript. */ @@ -6028,6 +6037,8 @@ static void smtpd_proto(SMTPD_STATE *state) state->error_mask |= MAIL_ERROR_PROTOCOL; smtpd_chat_reply(state, "500 5.5.2 Error: bad syntax"); state->error_count++; + state->where = SMTPD_CMD_UNKNOWN; + smtpd_cmdp_unknown->total_count += 1; continue; } /* Ignore smtpd_noop_cmds lookup errors. Non-critical feature. */ @@ -6036,6 +6047,7 @@ static void smtpd_proto(SMTPD_STATE *state) smtpd_chat_reply(state, "250 2.0.0 Ok"); if (state->junk_cmds++ > var_smtpd_junk_cmd_limit) state->error_count++; + /* XXX We can't count these. */ continue; } for (cmdp = smtpd_cmd_table; cmdp->name != 0; cmdp++)