{
DEBUG_VALIDATE_BUG_ON(state->curr_tx == NULL);
if (state->curr_tx)
- state->curr_tx->done = 1;
+ state->curr_tx->done = true;
}
/**
} else if (state->current_line_len >= 4 &&
SCMemcmpLowercase("data", state->current_line, 4) == 0) {
state->current_command = SMTP_COMMAND_DATA;
- if (smtp_config.raw_extraction) {
+ if (state->curr_tx->is_data) {
+ // We did not receive a confirmation from server
+ // And now the sends a next DATA
+ SMTPSetEvent(state, SMTP_DECODER_EVENT_UNPARSABLE_CONTENT);
+ SCReturnInt(0);
+ } else if (smtp_config.raw_extraction) {
const char *msgname = "rawmsg"; /* XXX have a better name */
if (state->files_ts == NULL)
state->files_ts = FileContainerAlloc();
if (state->files_ts == NULL) {
return -1;
}
- if (state->tx_cnt > 1 && !state->curr_tx->done) {
- // we did not close the previous tx, set error
- SMTPSetEvent(state, SMTP_DECODER_EVENT_UNPARSABLE_CONTENT);
- FileCloseFile(state->files_ts, NULL, 0, FILE_TRUNCATED);
- tx = SMTPTransactionCreate(state);
- if (tx == NULL)
- return -1;
- state->curr_tx = tx;
- TAILQ_INSERT_TAIL(&state->tx_list, tx, next);
- tx->tx_id = state->tx_cnt++;
- }
if (FileOpenFileWithId(state->files_ts, &smtp_config.sbcfg,
state->file_track_id++,
(uint8_t*) msgname, strlen(msgname), NULL, 0,
SMTPNewFile(state->curr_tx, state->files_ts->tail);
}
} else if (smtp_config.decode_mime) {
- if (tx->mime_state) {
- /* We have 2 chained mails and did not detect the end
- * of first one. So we start a new transaction. */
- tx->mime_state->state_flag = PARSE_ERROR;
- SMTPSetEvent(state, SMTP_DECODER_EVENT_UNPARSABLE_CONTENT);
- tx = SMTPTransactionCreate(state);
- if (tx == NULL)
- return -1;
- state->curr_tx = tx;
- TAILQ_INSERT_TAIL(&state->tx_list, tx, next);
- tx->tx_id = state->tx_cnt++;
- }
+ DEBUG_VALIDATE_BUG_ON(tx->mime_state);
tx->mime_state = MimeDecInitParser(f, SMTPProcessDataChunk);
if (tx->mime_state == NULL) {
return MIME_DEC_ERR_MEM;
tx->msg_tail = tx->mime_state->msg;
}
}
+ state->curr_tx->is_data = true;
/* Enter immediately data mode without waiting for server reply */
if (state->parser_state & SMTP_PARSER_STATE_PIPELINING_SERVER) {
state->parser_state |= SMTP_PARSER_STATE_COMMAND_DATA_MODE;