aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@iki.fi>2013-02-25 00:45:10 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2013-03-18 18:45:15 +0100
commit236f222cde03b2594732dacdfe031c7c16e20f4a (patch)
treed2f47b5f66fcb59bae27a0a294fb11070998b852
parenta8ba0a0d0ce4fa5f5afd0a8246e2378c2664c424 (diff)
downloadbusybox-236f222cde03b2594732dacdfe031c7c16e20f4a.tar.gz
sendmail: support long header fields for recipients
Support long header fields in To:, Cc: and Bcc: headers. Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--mailutils/sendmail.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c
index c5df5f5d3..22f735b3d 100644
--- a/mailutils/sendmail.c
+++ b/mailutils/sendmail.c
@@ -181,6 +181,12 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
char *host = sane_address(safe_gethostname());
unsigned nheaders = 0;
int code;
+ enum {
+ HDR_OTHER = 0,
+ HDR_TOCC,
+ HDR_BCC,
+ } last_hdr = 0;
+ int check_hdr;
enum {
//--- standard options
@@ -345,20 +351,31 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
if (opts & OPT_t) {
if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) {
rcptto_list(s+3);
+ last_hdr = HDR_TOCC;
goto addheader;
}
// Bcc: header adds blind copy (hidden) recipient
if (0 == strncasecmp("Bcc:", s, 4)) {
rcptto_list(s+4);
free(s);
+ last_hdr = HDR_BCC;
continue; // N.B. Bcc: vanishes from headers!
}
}
- if (strchr(s, ':') || (list && isspace(s[0]))) {
+ check_hdr = list && isspace(s[0]);
+ if (strchr(s, ':') || check_hdr) {
// other headers go verbatim
// N.B. RFC2822 2.2.3 "Long Header Fields" allows for headers to occupy several lines.
// Continuation is denoted by prefixing additional lines with whitespace(s).
// Thanks (stefan.seyfried at googlemail.com) for pointing this out.
+ if (check_hdr && last_hdr != HDR_OTHER) {
+ rcptto_list(s+1);
+ if (last_hdr == HDR_BCC)
+ continue;
+ // N.B. Bcc: vanishes from headers!
+ } else {
+ last_hdr = HDR_OTHER;
+ }
addheader:
// N.B. we allow MAX_HEADERS generic headers at most to prevent attacks
if (MAX_HEADERS && ++nheaders >= MAX_HEADERS)