(smtp_send_message): Correctly handle long
header lines. Fixes bug reported by William MacBain <macbain@ott-fortimail.dnsalias.org>
Showing
1 changed file
with
13 additions
and
4 deletions
... | @@ -708,21 +708,30 @@ smtp_send_message (mailer_t mailer, message_t argmsg, address_t argfrom, | ... | @@ -708,21 +708,30 @@ smtp_send_message (mailer_t mailer, message_t argmsg, address_t argfrom, |
708 | 708 | ||
709 | message_get_header (smtp->msg, &hdr); | 709 | message_get_header (smtp->msg, &hdr); |
710 | header_get_stream (hdr, &stream); | 710 | header_get_stream (hdr, &stream); |
711 | while ((status = stream_readline (stream, data, sizeof (data) - 1, | 711 | while ((status = stream_readline (stream, data, sizeof (data), |
712 | smtp->offset, &n)) == 0 && n > 0) | 712 | smtp->offset, &n)) == 0 && n > 0) |
713 | { | 713 | { |
714 | int nl; | ||
715 | |||
714 | found_nl = (n == 1 && data[0] == '\n'); | 716 | found_nl = (n == 1 && data[0] == '\n'); |
715 | if (data[n - 1] == '\n') | 717 | if ((nl = (data[n - 1] == '\n'))) |
716 | data[n - 1] = '\0'; | 718 | data[n - 1] = '\0'; |
717 | if (data[0] == '.') | 719 | if (data[0] == '.') |
718 | { | 720 | { |
719 | status = smtp_writeline (smtp, ".%s\r\n", data); | 721 | status = smtp_writeline (smtp, ".%s", data); |
720 | CHECK_ERROR (smtp, status); | 722 | CHECK_ERROR (smtp, status); |
721 | } | 723 | } |
722 | else if (strncasecmp (data, MU_HEADER_FCC, | 724 | else if (strncasecmp (data, MU_HEADER_FCC, |
723 | sizeof (MU_HEADER_FCC) - 1)) | 725 | sizeof (MU_HEADER_FCC) - 1)) |
724 | { | 726 | { |
725 | status = smtp_writeline (smtp, "%s\r\n", data); | 727 | status = smtp_writeline (smtp, "%s", data); |
728 | CHECK_ERROR (smtp, status); | ||
729 | status = smtp_write (smtp); | ||
730 | CHECK_EAGAIN (smtp, status); | ||
731 | } | ||
732 | if (nl) | ||
733 | { | ||
734 | status = smtp_writeline (smtp, "\r\n"); | ||
726 | CHECK_ERROR (smtp, status); | 735 | CHECK_ERROR (smtp, status); |
727 | status = smtp_write (smtp); | 736 | status = smtp_write (smtp); |
728 | CHECK_EAGAIN (smtp, status); | 737 | CHECK_EAGAIN (smtp, status); | ... | ... |
-
Please register or sign in to post a comment