diff options
-rw-r--r-- | mailutils/sendmail.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index c426e9d85..4f73512e9 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c | |||
@@ -94,9 +94,22 @@ static char *sane_address(char *str) | |||
94 | { | 94 | { |
95 | char *s = str; | 95 | char *s = str; |
96 | char *p = s; | 96 | char *p = s; |
97 | int leading_space = 1; | ||
98 | int trailing_space = 0; | ||
99 | |||
97 | while (*s) { | 100 | while (*s) { |
98 | if (isalnum(*s) || '_' == *s || '-' == *s || '.' == *s || '@' == *s) { | 101 | if (isspace(*s)) { |
102 | trailing_space = !leading_space; | ||
103 | } else { | ||
99 | *p++ = *s; | 104 | *p++ = *s; |
105 | if ((!isalnum(*s) && !strchr("_-.@", *s)) || | ||
106 | trailing_space) { | ||
107 | *p = '\0'; | ||
108 | bb_error_msg("Bad address: %s", str); | ||
109 | *str = '\0'; | ||
110 | return str; | ||
111 | } | ||
112 | leading_space = 0; | ||
100 | } | 113 | } |
101 | s++; | 114 | s++; |
102 | } | 115 | } |
@@ -106,6 +119,8 @@ static char *sane_address(char *str) | |||
106 | 119 | ||
107 | static void rcptto(const char *s) | 120 | static void rcptto(const char *s) |
108 | { | 121 | { |
122 | if (!*s) | ||
123 | return; | ||
109 | // N.B. we don't die if recipient is rejected, for the other recipients may be accepted | 124 | // N.B. we don't die if recipient is rejected, for the other recipients may be accepted |
110 | if (250 != smtp_checkp("RCPT TO:<%s>", s, -1)) | 125 | if (250 != smtp_checkp("RCPT TO:<%s>", s, -1)) |
111 | bb_error_msg("Bad recipient: <%s>", s); | 126 | bb_error_msg("Bad recipient: <%s>", s); |