From: Stephan Bosch Date: Sat, 9 Feb 2019 12:55:22 +0000 (+0100) Subject: lib-smtp: smtp-client - Perform the LF -> CRLF conversion for the message data in... X-Git-Tag: 2.3.7~101 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f23d30fad4dfcb6e303130bdfe3258eddbd7508;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-client - Perform the LF -> CRLF conversion for the message data in the transaction. Before, it was performed in the DATA/BDAT command code, which makes it very difficult to extract post-conversion size statistics. --- diff --git a/src/lib-smtp/smtp-client-command.c b/src/lib-smtp/smtp-client-command.c index 2ed1b43c20..7803ab5726 100644 --- a/src/lib-smtp/smtp-client-command.c +++ b/src/lib-smtp/smtp-client-command.c @@ -6,7 +6,6 @@ #include "str.h" #include "llist.h" #include "istream.h" -#include "istream-crlf.h" #include "ostream.h" #include "ostream-dot.h" #include "smtp-common.h" @@ -1457,11 +1456,11 @@ smtp_client_command_data_submit_after( /* capture abort event with our context */ smtp_client_command_set_abort_callback(cmd, _cmd_data_abort_cb, ctx); + ctx->data = data; + i_stream_ref(data); + if ((conn->caps.standard & SMTP_CAPABILITY_CHUNKING) == 0) { /* DATA */ - ctx->data = data; - i_stream_ref(data); - p_array_init(&ctx->cmds, ctx->pool, 1); /* Data stream is sent in one go in the second stage. Since the data @@ -1479,8 +1478,6 @@ smtp_client_command_data_submit_after( } else { /* BDAT */ - ctx->data = data = i_stream_create_crlf(data); - p_array_init(&ctx->cmds, ctx->pool, conn->set.max_data_chunk_pipeline); diff --git a/src/lib-smtp/smtp-client-command.h b/src/lib-smtp/smtp-client-command.h index a1d95400ba..e723bbb781 100644 --- a/src/lib-smtp/smtp-client-command.h +++ b/src/lib-smtp/smtp-client-command.h @@ -233,7 +233,8 @@ smtp_client_command_rcpt_submit( (smtp_client_command_callback_t *)callback, context) /* Send message data using DATA or BDAT (preferred if supported). - This handles the DATA 354 response implicitly. + This handles the DATA 354 response implicitly. Making sure that the data has + CRLF line endings consistently is the responsibility of the caller. */ struct smtp_client_command * smtp_client_command_data_submit_after( diff --git a/src/lib-smtp/smtp-client-transaction.c b/src/lib-smtp/smtp-client-transaction.c index 36ab444580..58ade75e47 100644 --- a/src/lib-smtp/smtp-client-transaction.c +++ b/src/lib-smtp/smtp-client-transaction.c @@ -5,6 +5,7 @@ #include "ioloop.h" #include "net.h" #include "istream.h" +#include "istream-crlf.h" #include "ostream.h" #include "str.h" #include "dns-lookup.h" @@ -1204,8 +1205,7 @@ void smtp_client_transaction_send( trans->data_provided = TRUE; i_assert(trans->data_input == NULL); - trans->data_input = data_input; - i_stream_ref(data_input); + trans->data_input = i_stream_create_crlf(data_input); trans->data_callback = data_callback; trans->data_context = data_context;