Skip to content

Commit 4fe336b

Browse files
committed
smtp: handle mid-session helo/ehlo like rset
RFC 5321 says a mid-session EHLO should work just like RSET. We more or less ignored it, which meant transaction state could carry over. Treat a HELO/EHLO received during a transaction as RSET once the server accepts it. Ticket: OISF#8715
1 parent 0fbec65 commit 4fe336b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/app-layer-smtp.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,17 @@ static int SMTPProcessRequest(
14141414
if (r == -1) {
14151415
SCReturnInt(-1);
14161416
}
1417-
state->current_command = SMTP_COMMAND_OTHER_CMD;
1417+
if (state->curr_tx->mail_from != NULL || !TAILQ_EMPTY(&state->curr_tx->rcpt_to_list) ||
1418+
state->curr_tx->progress_ts != SMTP_REQUEST_STARTED) {
1419+
/* Mid-session HELO/EHLO resets the state as if a RSET
1420+
* had been issued (RFC 5321 4.1.4). The progress check
1421+
* catches a transaction with no envelope but an attempted
1422+
* DATA or BDAT, such as a rejected envelope-less DATA. */
1423+
state->bdat_chunk_idx = 0;
1424+
state->current_command = SMTP_COMMAND_RSET;
1425+
} else {
1426+
state->current_command = SMTP_COMMAND_OTHER_CMD;
1427+
}
14181428
} else if (line->len >= 9 && SCMemcmpLowercase("mail from", line->buf, 9) == 0) {
14191429
r = SMTPParseCommandMAILFROM(state, line);
14201430
if (r == -1) {

0 commit comments

Comments
 (0)