From 8c34c611e07d3678920b9f13ba2ae627eb0255e9 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Wed, 18 Jul 2018 22:59:14 +0100 Subject: I18N: reject SMTPUTF8 MAIL command when facility not advertised --- doc/doc-txt/ChangeLog | 4 ++++ src/src/smtp_in.c | 26 +++++++++++++++----------- test/log/4201 | 1 + test/scripts/4200-International/4201 | 21 +++++++++++++++++++++ test/stdout/4201 | 21 +++++++++++++++++++++ 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index fbca09fb3..5b8ada93a 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -81,6 +81,10 @@ JH/18 Bug 2287: Fix the protocol name (eg utf8esmtp) for multiple messages using the SMTPUTF8 option on their MAIL FROM commands, in one connection. Previously the "utf8" would be re-prepended for every additional message. +JH/19 Reject MAIL FROM commands with SMTPUTF8 when the facility was not advertised. + Previously thery were accepted, resulting in issues when attempting to + forward messages to a non-supporting MTA. + Exim version 4.91 ----------------- diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 6e2c45a8c..ff0f6acaa 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -4580,7 +4580,7 @@ while (done <= 0) if (dsn_advertised) { /* Check if the dsn envid has been already set */ - if (dsn_envid != NULL) + if (dsn_envid) { synprot_error(L_smtp_syntax_error, 501, NULL, US"ENVID can be specified once only"); @@ -4669,17 +4669,21 @@ while (done <= 0) #ifdef SUPPORT_I18N case ENV_MAIL_OPT_UTF8: - if (smtputf8_advertised) + if (!smtputf8_advertised) { - DEBUG(D_receive) debug_printf("smtputf8 requested\n"); - message_smtputf8 = allow_utf8_domains = TRUE; - if (Ustrncmp(received_protocol, US"utf8", 4) != 0) - { - int old_pool = store_pool; - store_pool = POOL_PERM; - received_protocol = string_sprintf("utf8%s", received_protocol); - store_pool = old_pool; - } + synprot_error(L_smtp_syntax_error, 501, NULL, + US"SMTPUTF8 used when not advertised"); + goto COMMAND_LOOP; + } + + DEBUG(D_receive) debug_printf("smtputf8 requested\n"); + message_smtputf8 = allow_utf8_domains = TRUE; + if (Ustrncmp(received_protocol, US"utf8", 4) != 0) + { + int old_pool = store_pool; + store_pool = POOL_PERM; + received_protocol = string_sprintf("utf8%s", received_protocol); + store_pool = old_pool; } break; #endif diff --git a/test/log/4201 b/test/log/4201 index 6b7c6ac97..7b299c06a 100644 --- a/test/log/4201 +++ b/test/log/4201 @@ -18,3 +18,4 @@ 1999-03-02 09:44:33 10HmaY-0005vi-00 => :blackhole: R=localuser 1999-03-02 09:44:33 10HmaY-0005vi-00 Completed 1999-03-02 09:44:33 End queue run: pid=pppp -qqff +1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225 diff --git a/test/scripts/4200-International/4201 b/test/scripts/4200-International/4201 index fc9a50741..5a591fdea 100644 --- a/test/scripts/4200-International/4201 +++ b/test/scripts/4200-International/4201 @@ -84,4 +84,25 @@ QUIT killdaemon exim -DSERVER=server -DNOTDAEMON -qqff **** +# +# +# Attempt to use when not advertised +exim -DSERVER=server -DOPTION=: -bd -oX PORT_D +**** +client 127.0.0.1 PORT_D +??? 220 +EHLO client +??? 250- +??? 250-SIZE +??? 250-8BITMIME +??? 250-PIPELINING +??? 250 HELP +MAIL FROM: SMTPUTF8 +??? 501 +QUIT +??? 221 +**** +killdaemon +# +# no_msglog_check diff --git a/test/stdout/4201 b/test/stdout/4201 index 08f6f1145..9c95da74e 100644 --- a/test/stdout/4201 +++ b/test/stdout/4201 @@ -95,3 +95,24 @@ End of script 354 Enter message, ending with "." on a line by itself 250 OK id=10HmaX-0005vi-00 221 the.local.host.name closing connection +Connecting to 127.0.0.1 port 1225 ... connected +??? 220 +<<< 220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +>>> EHLO client +??? 250- +<<< 250-the.local.host.name Hello client [127.0.0.1] +??? 250-SIZE +<<< 250-SIZE 52428800 +??? 250-8BITMIME +<<< 250-8BITMIME +??? 250-PIPELINING +<<< 250-PIPELINING +??? 250 HELP +<<< 250 HELP +>>> MAIL FROM: SMTPUTF8 +??? 501 +<<< 501 SMTPUTF8 used when not advertised +>>> QUIT +??? 221 +<<< 221 the.local.host.name closing connection +End of script -- cgit v1.2.3