CHUNKING: after rejecting a pipelined SMTP command, flush any followon BDAT data
[exim.git] / src / src / smtp_in.c
index 09356c23115d3d7a71be033d3842c306a321940f..597b88e389421493f84a79f616edf9f92bf5c4dc 100644 (file)
@@ -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;
       }