Skip to content

Commit 5dd365f

Browse files
committed
smtp: treat a mid-session helo/ehlo like a rset
A HELO or EHLO issued later in the session must clear all buffers and reset the state exactly as if a RSET had been issued (RFC 5321 4.1.4). Instead it was ignored, merging the next envelope into the abandoned one and attributing the delivered message to the abandoned sender. Handle a HELO/EHLO arriving after an envelope has been started like a RSET, completing the transaction on the server's 250 reply. Ticket: OISF#8715
1 parent 0fbec65 commit 5dd365f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/app-layer-smtp.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,15 @@ 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 ||
1418+
!TAILQ_EMPTY(&state->curr_tx->rcpt_to_list)) {
1419+
/* Mid-session HELO/EHLO resets the state as if a RSET
1420+
* had been issued (RFC 5321 4.1.4). */
1421+
state->bdat_chunk_idx = 0;
1422+
state->current_command = SMTP_COMMAND_RSET;
1423+
} else {
1424+
state->current_command = SMTP_COMMAND_OTHER_CMD;
1425+
}
14181426
} else if (line->len >= 9 && SCMemcmpLowercase("mail from", line->buf, 9) == 0) {
14191427
r = SMTPParseCommandMAILFROM(state, line);
14201428
if (r == -1) {

0 commit comments

Comments
 (0)