]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: Prevent sending an empty XCLIENT command when the first parameter...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 3 Dec 2018 23:16:47 +0000 (00:16 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 3 Dec 2018 23:16:47 +0000 (00:16 +0100)
src/lib-smtp/smtp-client-connection.c

index c1e548890cacf80dec656e3bb9b6bb760281de60..3c6d3f1c2714f08a20b0530bfb0e993cf4f4cf82 100644 (file)
@@ -683,12 +683,15 @@ smtp_client_connection_xclient_add(struct smtp_client_connection *conn,
        size_t prev_offset = str_len(str);
        const char *new_field;
 
+       i_assert(prev_offset >= offset);
+
        str_append_c(str, ' ');
        str_append(str, field);
        str_append_c(str, '=');
        smtp_xtext_encode_cstr(str, value);
 
-       if (str_len(str) <= SMTP_CLIENT_BASE_LINE_LENGTH_LIMIT)
+       if (prev_offset == offset ||
+           str_len(str) <= SMTP_CLIENT_BASE_LINE_LENGTH_LIMIT)
                return;
                
        /* preserve field we just added */