From: Timo Sirainen Date: Mon, 21 Mar 2011 16:51:51 +0000 (+0200) Subject: lmtp/smtp client: Crashfix if remote returned failure to RCPT TO. X-Git-Tag: 2.0.12~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=089a5b2ce24eff98ad5151b46794fbd9bb7095e2;p=thirdparty%2Fdovecot%2Fcore.git lmtp/smtp client: Crashfix if remote returned failure to RCPT TO. --- diff --git a/src/lib-lda/lmtp-client.c b/src/lib-lda/lmtp-client.c index bdd6a71e1a..db928100a6 100644 --- a/src/lib-lda/lmtp-client.c +++ b/src/lib-lda/lmtp-client.c @@ -206,16 +206,18 @@ lmtp_client_rcpt_next(struct lmtp_client *client, const char *line) rcpt->rcpt_to_callback(success, line, rcpt->context); } -static void lmtp_client_send_data_cmd(struct lmtp_client *client) +static int lmtp_client_send_data_cmd(struct lmtp_client *client) { if (client->rcpt_next_receive_idx < array_count(&client->recipients)) - return; + return 0; - if (client->global_fail_string != NULL || !client->rcpt_to_successes) + if (client->global_fail_string != NULL || !client->rcpt_to_successes) { lmtp_client_fail(client, client->global_fail_string); - else { + return -1; + } else { client->input_state++; o_stream_send_str(client->output, "DATA\r\n"); + return 0; } } @@ -390,7 +392,8 @@ static int lmtp_client_input_line(struct lmtp_client *client, const char *line) lmtp_client_rcpt_next(client, line); if (client->data_input == NULL) break; - lmtp_client_send_data_cmd(client); + if (lmtp_client_send_data_cmd(client) < 0) + return -1; break; case LMTP_INPUT_STATE_DATA_CONTINUE: /* Start sending DATA */ @@ -584,7 +587,7 @@ void lmtp_client_send(struct lmtp_client *client, struct istream *data_input) i_stream_ref(data_input); client->data_input = data_input; - lmtp_client_send_data_cmd(client); + (void)lmtp_client_send_data_cmd(client); } void lmtp_client_send_more(struct lmtp_client *client)