Skip to content

Commit

Permalink
lib-smtp: client: BDAT command: Make sure the message contains CRLF c…
Browse files Browse the repository at this point in the history
…onsistently.

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.
  • Loading branch information
stephanbosch authored and sirainen committed Jan 18, 2019
1 parent 7b4cc47 commit 7a456f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib-smtp/smtp-client-command.c
Expand Up @@ -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"
Expand Down Expand Up @@ -1330,14 +1331,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
Expand All @@ -1355,6 +1357,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);

Expand Down

0 comments on commit 7a456f2

Please sign in to comment.