CHUNKING: fix second message on conn when first rejected
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 26 May 2022 12:46:08 +0000 (13:46 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 26 May 2022 14:44:47 +0000 (15:44 +0100)
doc/doc-txt/ChangeLog
src/src/smtp_in.c
test/log/0900
test/rejectlog/0900
test/scripts/0000-Basic/0900
test/stdout/0900

index 389968a9033f691bb9d7c3736a51cbfcb10f7bda..ff35328a1643cc2daea9261a1b19879af785b387 100644 (file)
@@ -140,6 +140,11 @@ JH/31 Bug 2886: GnuTLS: Do not free the cached creds on transport connection
       close; it may be needed for a subsequent connection.  This caused a
       SEGV on primary-MX defer.  Found/investigated by Gedalya & Andreas.
 
+JH/32 Fix CHUNKING for a second message on a connection when the first was
+      rejected.  Previously we did not reset the chunking-offered state, and
+      erroneously rejected the BDAT command.  Investigation help from
+      Jesse Hathaway.
+
 
 Exim version 4.95
 -----------------
index 7a4eaf99681da1e740d2b44b0bca132edf708d70..752e80dca4887cc97fe099046bfbece520420783 100644 (file)
@@ -840,12 +840,8 @@ while (chunking_data_left)
   }
 
 bdat_pop_receive_functions();
-
-if (chunking_state != CHUNKING_LAST)
-  {
-  chunking_state = CHUNKING_OFFERED;
-  DEBUG(D_receive) debug_printf("chunking state %d\n", (int)chunking_state);
-  }
+chunking_state = CHUNKING_OFFERED;
+DEBUG(D_receive) debug_printf("chunking state %d\n", (int)chunking_state);
 }
 
 
@@ -978,7 +974,7 @@ which sometimes uses smtp_printf() and sometimes smtp_respond(). */
 
 if (fl.rcpt_in_progress)
   {
-  if (rcpt_smtp_response == NULL)
+  if (!rcpt_smtp_response)
     rcpt_smtp_response = string_copy(big_buffer);
   else if (fl.rcpt_smtp_response_same &&
            Ustrcmp(rcpt_smtp_response, big_buffer) != 0)
@@ -5081,7 +5077,7 @@ while (done <= 0)
       count this as a protocol error. Reset was_rej_mail so that further RCPTs
       get the same treatment. */
 
-      if (sender_address == NULL)
+      if (!sender_address)
        {
        if (f.smtp_in_pipelining_advertised && last_was_rej_mail)
          {
@@ -5100,7 +5096,7 @@ while (done <= 0)
 
       /* Check for an operand */
 
-      if (smtp_cmd_data[0] == 0)
+      if (!smtp_cmd_data[0])
        {
        done = synprot_error(L_smtp_syntax_error, 501, NULL,
          US"RCPT must have an address operand");
index 85ba6d730a2f9a5740bcc5c67cab5698123c185b..bab7506092ad86be5702a5b9f2c7ab94df9468bc 100644 (file)
@@ -4,10 +4,14 @@
 2017-07-30 18:51:05.712 10HmaX-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
 2017-07-30 18:51:05.712 10HmaY-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
 2017-07-30 18:51:05.712 10HmaZ-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
-2017-07-30 18:51:05.712 10HmbA-0005vi-00 SMTP data timeout (message abandoned) on connection from (tester) [127.0.0.1] F=<someone@some.domain>
+2017-07-30 18:51:05.712 10HmbA-0005vi-00 <= some_ne@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
+2017-07-30 18:51:05.712 10HmbB-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
+2017-07-30 18:51:05.712 10HmbC-0005vi-00 SMTP data timeout (message abandoned) on connection from (tester) [127.0.0.1] F=<someone@some.domain>
 2017-07-30 18:51:05.712 SMTP connection from (tester) [127.0.0.1] lost while reading message data
 2017-07-30 18:51:05.712 SMTP connection from (tester) [127.0.0.1] lost while reading message data
-2017-07-30 18:51:05.712 10HmbB-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
+2017-07-30 18:51:05.712 10HmbD-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
 2017-07-30 18:51:05.712 H=(tester) [127.0.0.1] F=<someone@some.domain> rejected RCPT <dummy@reject.ex>: relay not permitted
+2017-07-30 18:51:05.712 H=(tester) [127.0.0.1] F=<some3ne@some.domain> rejected RCPT <dummy@reject.ex>: relay not permitted
+2017-07-30 18:51:05.712 H=(tester) [127.0.0.1] F=<some4ne@some.domain> rejected RCPT <dummy@reject.ex>: relay not permitted
 2017-07-30 18:51:05.712 rejected from <someone@some.domain> H=(tester) [127.0.0.1]: Non-CRLF-terminated header, under CHUNKING: message abandoned
-2017-07-30 18:51:05.712 10HmbC-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
+2017-07-30 18:51:05.712 10HmbE-0005vi-00 <= someone@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
index 5e1c0372cf72e31b236a98a00fd9f1121d986463..e39b7c5885eb3706b11389f7d2ee7c6387c1bf16 100644 (file)
@@ -1,6 +1,8 @@
 
 ******** SERVER ********
 2017-07-30 18:51:05.712 H=(tester) [127.0.0.1] F=<someone@some.domain> rejected RCPT <dummy@reject.ex>: relay not permitted
+2017-07-30 18:51:05.712 H=(tester) [127.0.0.1] F=<some3ne@some.domain> rejected RCPT <dummy@reject.ex>: relay not permitted
+2017-07-30 18:51:05.712 H=(tester) [127.0.0.1] F=<some4ne@some.domain> rejected RCPT <dummy@reject.ex>: relay not permitted
 2017-07-30 18:51:05.712 rejected from <someone@some.domain> H=(tester) [127.0.0.1]: Non-CRLF-terminated header, under CHUNKING: message abandoned
 Envelope-from: <someone@some.domain>
 Envelope-to: <CALLER@test.ex>
index 1c0e43552eb160d5d90a5b0e71c085e4dec5b232..a8d2b05399c53dbd54628e635dc2c2f550fe10db 100644 (file)
@@ -66,6 +66,51 @@ random.com
 From: Sam@random.com
 Subject: This is a bodyless test message
 
+??? 250-
+??? 250
+quit
+??? 221
+****
+#
+# Same again but with RSET between the two
+client 127.0.0.1 PORT_D
+??? 220
+ehlo tester
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250
+mail from:some_ne@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 100
+To: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyfull test message
+
+1234567890
+??? 250
+noop
+??? 250
+bdat 0 last
+??? 250-
+??? 250
+RSET
+??? 250
+mail from:someone@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 10
+To: Susan@bdat 78 last
+??? 250
+random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
+
 ??? 250-
 ??? 250
 quit
@@ -215,6 +260,43 @@ quit
 ??? 221
 ****
 #
+# Two rejected messages, pipielined, REST between
+client 127.0.0.1 PORT_D
+??? 220
+EHLO tester
+??? 250-
+??? 250-SIZE
+??? 250-8BITMIME
+??? 250-PIPELINING
+??? 250-CHUNKING
+??? 250 HELP
+MAIL FROM:<some3ne@some.domain>\r\nRCPT TO:<dummy@reject.ex>\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 relay not permitted
+??? 503-All RCPT commands were rejected
+??? 503-
+??? 503
+??? 503-All RCPT commands were rejected
+??? 503-
+??? 503
+RSET
+??? 250
+NOOP
+??? 250
+MAIL FROM:<some4ne@some.domain>\r\nRCPT TO:<dummy@reject.ex>\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-All RCPT commands were rejected
+??? 503-
+??? 503
+??? 503-
+??? 503-
+??? 503
+quit
+??? 221
+****
+#
+#
 # plain, small message (no body)
 # header line with bad line-ending
 client 127.0.0.1 PORT_D
index ccd10f0a1b68d3e9ab70d6799f9a69b6cdcfa2c2..bcb177fb614036529da5835f9c0adbc6179e4ac1 100644 (file)
@@ -109,6 +109,69 @@ Connecting to 127.0.0.1 port 1225 ... connected
 <<< 250-CHUNKING
 ??? 250
 <<< 250 HELP
+>>> mail from:some_ne@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 100
+>>> To: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyfull test message
+>>> 
+>>> 1234567890
+??? 250
+<<< 250 100 byte chunk received
+>>> noop
+??? 250
+<<< 250 OK
+>>> bdat 0 last
+??? 250-
+<<< 250- 0 byte chunk, total 100
+??? 250
+<<< 250 OK id=10HmbA-0005vi-00
+>>> RSET
+??? 250
+<<< 250 Reset OK
+>>> mail from:someone@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 10
+>>> To: Susan@bdat 78 last
+??? 250
+<<< 250 10 byte chunk received
+>>> random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>> 
+??? 250-
+<<< 250- 78 byte chunk, total 88
+??? 250
+<<< 250 OK id=10HmbB-0005vi-00
+>>> quit
+??? 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-
+<<< 250-SIZE 52428800
+??? 250-
+<<< 250-8BITMIME
+??? 250-
+<<< 250-PIPELINING
+??? 250-
+<<< 250-CHUNKING
+??? 250
+<<< 250 HELP
 >>> mail from:someone@some.domain
 ??? 250
 <<< 250 OK
@@ -254,7 +317,7 @@ Connecting to 127.0.0.1 port 1225 ... connected
 ??? 250-
 <<< 250- 88 byte chunk, total 88
 ??? 250
-<<< 250 OK id=10HmbB-0005vi-00
+<<< 250 OK id=10HmbD-0005vi-00
 >>> quit
 ??? 221
 <<< 221 testhost.test.ex closing connection
@@ -299,6 +362,66 @@ 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:<some3ne@some.domain>\r\nRCPT TO:<dummy@reject.ex>\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 relay not permitted
+<<< 550 relay not permitted
+??? 503-All RCPT commands were rejected
+<<< 503-All RCPT commands were rejected with this error:
+??? 503-
+<<< 503-relay not permitted
+??? 503
+<<< 503 Valid RCPT command must precede BDAT
+??? 503-All RCPT commands were rejected
+<<< 503-All RCPT commands were rejected with this error:
+??? 503-
+<<< 503-relay not permitted
+??? 503
+<<< 503 valid RCPT command must precede BDAT
+>>> RSET
+??? 250
+<<< 250 Reset OK
+>>> NOOP
+??? 250
+<<< 250 OK
+>>> MAIL FROM:<some4ne@some.domain>\r\nRCPT TO:<dummy@reject.ex>\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-All RCPT commands were rejected
+<<< 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
+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]
@@ -360,7 +483,7 @@ Connecting to 127.0.0.1 port 1225 ... connected
 ??? 250-
 <<< 250- 98 byte chunk, total 100
 ??? 250
-<<< 250 OK id=10HmbC-0005vi-00
+<<< 250 OK id=10HmbE-0005vi-00
 >>> quit
 ??? 221
 <<< 221 testhost.test.ex closing connection