smtp-server-cmd-rcpt.c (dovecot-2.3.16) | : | smtp-server-cmd-rcpt.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 26 | skipping to change at line 26 | |||
struct smtp_server_recipient *rcpt; | struct smtp_server_recipient *rcpt; | |||
}; | }; | |||
static void | static void | |||
cmd_rcpt_destroy(struct smtp_server_cmd_ctx *cmd ATTR_UNUSED, | cmd_rcpt_destroy(struct smtp_server_cmd_ctx *cmd ATTR_UNUSED, | |||
struct smtp_server_cmd_rcpt *data) | struct smtp_server_cmd_rcpt *data) | |||
{ | { | |||
smtp_server_recipient_destroy(&data->rcpt); | smtp_server_recipient_destroy(&data->rcpt); | |||
} | } | |||
static bool cmd_rcpt_check_state(struct smtp_server_cmd_ctx *cmd) | static bool | |||
cmd_rcpt_check_state(struct smtp_server_cmd_ctx *cmd, bool next_to_reply) | ||||
{ | { | |||
struct smtp_server_connection *conn = cmd->conn; | struct smtp_server_connection *conn = cmd->conn; | |||
struct smtp_server_command *command = cmd->cmd; | struct smtp_server_command *command = cmd->cmd; | |||
struct smtp_server_transaction *trans = conn->state.trans; | struct smtp_server_transaction *trans = conn->state.trans; | |||
if (smtp_server_command_is_replied(command) && | if (smtp_server_command_is_replied(command) && | |||
!smtp_server_command_replied_success(command) && | !smtp_server_command_replied_success(command) && | |||
!smtp_server_command_reply_is_forwarded(command)) | !smtp_server_command_reply_is_forwarded(command)) | |||
return FALSE; | return FALSE; | |||
if (conn->state.pending_mail_cmds == 0 && trans == NULL) { | if (trans == NULL && | |||
(conn->state.pending_mail_cmds == 0 || next_to_reply)) { | ||||
smtp_server_reply(cmd, | smtp_server_reply(cmd, | |||
503, "5.5.0", "MAIL needed first"); | 503, "5.5.0", "MAIL needed first"); | |||
return FALSE; | return FALSE; | |||
} | } | |||
if (conn->set.max_recipients > 0 && trans != NULL && | if (conn->set.max_recipients > 0 && trans != NULL && | |||
smtp_server_transaction_rcpt_count(trans) >= | smtp_server_transaction_rcpt_count(trans) >= | |||
conn->set.max_recipients) { | conn->set.max_recipients) { | |||
smtp_server_reply(cmd, | smtp_server_reply(cmd, | |||
451, "4.5.3", "Too many recipients"); | 451, "4.5.3", "Too many recipients"); | |||
return FALSE; | return FALSE; | |||
skipping to change at line 87 | skipping to change at line 89 | |||
data->rcpt = NULL; /* clear to prevent destruction */ | data->rcpt = NULL; /* clear to prevent destruction */ | |||
(void)smtp_server_recipient_approved(&rcpt); | (void)smtp_server_recipient_approved(&rcpt); | |||
} | } | |||
static void | static void | |||
cmd_rcpt_recheck(struct smtp_server_cmd_ctx *cmd, | cmd_rcpt_recheck(struct smtp_server_cmd_ctx *cmd, | |||
struct smtp_server_cmd_rcpt *data ATTR_UNUSED) | struct smtp_server_cmd_rcpt *data ATTR_UNUSED) | |||
{ | { | |||
struct smtp_server_connection *conn = cmd->conn; | struct smtp_server_connection *conn = cmd->conn; | |||
i_assert(conn->state.pending_mail_cmds == 0); | ||||
/* All preceeding commands have finished and now the transaction state | /* All preceeding commands have finished and now the transaction state | |||
is clear. This provides the opportunity to re-check the transaction | is clear. This provides the opportunity to re-check the transaction | |||
state and abort the pending proxied mail command if it is bound to | state and abort the pending proxied mail command if it is bound to | |||
fail */ | fail */ | |||
if (!cmd_rcpt_check_state(cmd)) | if (!cmd_rcpt_check_state(cmd, TRUE)) | |||
return; | return; | |||
/* Advance state */ | /* Advance state */ | |||
smtp_server_connection_set_state(conn, SMTP_SERVER_STATE_RCPT_TO, | smtp_server_connection_set_state(conn, SMTP_SERVER_STATE_RCPT_TO, | |||
smtp_address_encode(data->rcpt->path)); | smtp_address_encode(data->rcpt->path)); | |||
} | } | |||
void smtp_server_cmd_rcpt(struct smtp_server_cmd_ctx *cmd, | void smtp_server_cmd_rcpt(struct smtp_server_cmd_ctx *cmd, | |||
const char *params) | const char *params) | |||
{ | { | |||
skipping to change at line 126 | skipping to change at line 126 | |||
enum smtp_param_parse_error pperror; | enum smtp_param_parse_error pperror; | |||
const char *error; | const char *error; | |||
int ret; | int ret; | |||
/* rcpt = "RCPT TO:" ( "<Postmaster@" Domain ">" / | /* rcpt = "RCPT TO:" ( "<Postmaster@" Domain ">" / | |||
"<Postmaster>" / Forward-path ) [SP Rcpt-parameters] CRLF | "<Postmaster>" / Forward-path ) [SP Rcpt-parameters] CRLF | |||
Forward-path = Path | Forward-path = Path | |||
*/ | */ | |||
/* Check transaction state as far as possible */ | /* Check transaction state as far as possible */ | |||
if (!cmd_rcpt_check_state(cmd)) | if (!cmd_rcpt_check_state(cmd, FALSE)) | |||
return; | return; | |||
/* ( "<Postmaster@" Domain ">" / "<Postmaster>" / Forward-path ) */ | /* ( "<Postmaster@" Domain ">" / "<Postmaster>" / Forward-path ) */ | |||
if (params == NULL || strncasecmp(params, "TO:", 3) != 0) { | if (params == NULL || strncasecmp(params, "TO:", 3) != 0) { | |||
smtp_server_reply(cmd, | smtp_server_reply(cmd, | |||
501, "5.5.4", "Invalid parameters"); | 501, "5.5.4", "Invalid parameters"); | |||
return; | return; | |||
} | } | |||
if (params[3] != ' ' && params[3] != '\t') { | if (params[3] != ' ' && params[3] != '\t') { | |||
params += 3; | params += 3; | |||
End of changes. 5 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added |