]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: BDAT command: Make sure the message contains CRLF consistently.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 8 Sep 2018 18:54:54 +0000 (20:54 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 21 Mar 2019 08:02:36 +0000 (10:02 +0200)
Before, only messages sent using DATA command guaranteed consistent CRLF,
because these are sent using o_stream_dot(), which does that internally. For the
BDAT command, the message was sent as-is, which is not always accepted by MTAs.

src/lib-smtp/smtp-client-command.c

index 97536b74c63e1d95e34827ce9361a1edf96435c2..129c4b23c9c519e18955bb6891ec78caa58c4013 100644 (file)
@@ -6,6 +6,7 @@
 #include "str.h"
 #include "llist.h"
 #include "istream.h"
+#include "istream-crlf.h"
 #include "ostream.h"
 #include "ostream-dot.h"
 #include "smtp-common.h"
@@ -1324,14 +1325,15 @@ smtp_client_command_data_submit_after(
        ctx->conn = conn;
        ctx->pool = cmd->pool;
        ctx->cmd_data = cmd;
-       ctx->data = data;
-       i_stream_ref(data);
 
        /* capture abort event with our context */
        smtp_client_command_set_abort_callback(cmd, _cmd_data_abort_cb, ctx);
 
        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
@@ -1349,6 +1351,8 @@ smtp_client_command_data_submit_after(
 
        } else {
                /* BDAT */
+               ctx->data = i_stream_create_crlf(data);
+
                p_array_init(&ctx->cmds, ctx->pool,
                        conn->set.max_data_chunk_pipeline);