From: Jeremy Harris Date: Thu, 1 Sep 2016 17:25:58 +0000 (+0100) Subject: CHUNKING: after rejecting a pipelined SMTP command, flush any followon BDAT data X-Git-Tag: exim-4_88_RC1~22 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/45bd315dc080b8f77679ba5ae60e35b0d8c9e97c?ds=sidebyside CHUNKING: after rejecting a pipelined SMTP command, flush any followon BDAT data --- diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 09356c231..597b88e38 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -476,6 +476,20 @@ next_cmd: } } +static void +bdat_flush_data(void) +{ +while (chunking_data_left-- > 0) + if (lwr_receive_getc() < 0) + break; + +receive_getc = lwr_receive_getc; +receive_ungetc = lwr_receive_ungetc; + +if (chunking_state != CHUNKING_LAST) + chunking_state = CHUNKING_OFFERED; +} + @@ -4775,6 +4789,9 @@ while (done <= 0) smtp_connection_had[smtp_ch_index-1] == SCH_DATA ? US"valid RCPT command must precede DATA" : US"valid RCPT command must precede BDAT"); + + if (chunking_state > CHUNKING_OFFERED) + bdat_flush_data(); break; } diff --git a/test/log/0900 b/test/log/0900 index 32aeaca60..8ce3bcb0f 100644 --- a/test/log/0900 +++ b/test/log/0900 @@ -8,3 +8,4 @@ 1999-03-02 09:44:33 SMTP connection from (tester) [127.0.0.1] lost while reading message data 1999-03-02 09:44:33 SMTP connection from (tester) [127.0.0.1] lost while reading message data 1999-03-02 09:44:33 10HmbB-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex +1999-03-02 09:44:33 H=(tester) [127.0.0.1] F= rejected RCPT : relay not permitted diff --git a/test/scripts/0000-Basic/0900 b/test/scripts/0000-Basic/0900 index 9774e5747..9e014c43e 100644 --- a/test/scripts/0000-Basic/0900 +++ b/test/scripts/0000-Basic/0900 @@ -191,5 +191,29 @@ quit ??? 221 **** # +# plain, longer message (xple chunks), RCPT rejected +# pipelined +client 127.0.0.1 PORT_D +??? 220 +EHLO tester +??? 250- +??? 250-SIZE +??? 250-8BITMIME +??? 250-PIPELINING +??? 250-CHUNKING +??? 250 HELP +MAIL FROM:\r\nRCPT TO:\r\nBDAT 86\r\nTo: Susan@random.com\r\nFrom: Sal@random.com\r\nSubject: This is a bodyless test message\r\nBDAT 6 LAST\r\nZZ\r\n +??? 250 +??? 550 +??? 503- +??? 503- +??? 503 +??? 503- +??? 503- +??? 503 +quit +??? 221 +**** +# killdaemon no_msglog_check diff --git a/test/stdout/0900 b/test/stdout/0900 index bf6010f82..70c527c17 100644 --- a/test/stdout/0900 +++ b/test/stdout/0900 @@ -259,3 +259,40 @@ Connecting to 127.0.0.1 port 1225 ... connected ??? 221 <<< 221 testhost.test.ex closing connection End of script +Connecting to 127.0.0.1 port 1225 ... connected +??? 220 +<<< 220 testhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +>>> EHLO tester +??? 250- +<<< 250-testhost.test.ex Hello tester [127.0.0.1] +??? 250-SIZE +<<< 250-SIZE 52428800 +??? 250-8BITMIME +<<< 250-8BITMIME +??? 250-PIPELINING +<<< 250-PIPELINING +??? 250-CHUNKING +<<< 250-CHUNKING +??? 250 HELP +<<< 250 HELP +>>> MAIL FROM:\r\nRCPT TO:\r\nBDAT 86\r\nTo: Susan@random.com\r\nFrom: Sal@random.com\r\nSubject: This is a bodyless test message\r\nBDAT 6 LAST\r\nZZ\r\n +??? 250 +<<< 250 OK +??? 550 +<<< 550 relay not permitted +??? 503- +<<< 503-All RCPT commands were rejected with this error: +??? 503- +<<< 503-relay not permitted +??? 503 +<<< 503 Valid RCPT command must precede BDAT +??? 503- +<<< 503-All RCPT commands were rejected with this error: +??? 503- +<<< 503-relay not permitted +??? 503 +<<< 503 valid RCPT command must precede BDAT +>>> quit +??? 221 +<<< 221 testhost.test.ex closing connection +End of script