return -1;
}
+ /* The command queue must be empty at this point. If anything were to be
+ queued somehow, this connection is vulnerable to STARTTLS command
+ insertion.
+ */
+ i_assert(conn->command_queue_count == 0 &&
+ conn->command_queue_head == NULL);
+
/* RFC 3207, Section 4.2:
Upon completion of the TLS handshake, the SMTP protocol is reset to
const struct smtp_server_callbacks *callbacks = conn->callbacks;
int ret;
+ /* The command queue can only contain the STARTTLS command at this
+ point. If anything beyond the STARTTLS were queued somehow, this
+ connection is vulnerable to STARTTLS command insertion.
+ */
+ i_assert(conn->command_queue_count == 1 &&
+ conn->command_queue_tail == command);
+
smtp_server_connection_set_state(conn, SMTP_SERVER_STATE_STARTTLS,
NULL);
/* Parse commands */
ret = 1;
- while (!conn->closing && ret != 0) {
+ while (!conn->closing && !conn->input_locked && ret != 0) {
while ((ret = smtp_command_parse_next(
conn->smtp_parser, &cmd_name, &cmd_params,
&error_code, &error)) > 0) {
if (conn->disconnected)
return;
+ /* Last command locked the input; stop trying to read
+ more. */
+ if (conn->input_locked)
+ break;
/* Client indicated it will close after this command;
stop trying to read more. */
if (conn->closing)