← Commit list

14285d14a

Aaro Koskinen
Aaro Koskinen
2013-03-18
SUCCESS Duration: 184s

Subject

sendmail: avoid sending mail to wrong addresses

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

mailutils/sendmail.c+16 -1
@@ -94,9 +94,22 @@ static char *sane_address(char *str)
{
char *s = str;
char *p = s;
+ int leading_space = 1;
+ int trailing_space = 0;
+
while (*s) {
- if (isalnum(*s) || '_' == *s || '-' == *s || '.' == *s || '@' == *s) {
+ if (isspace(*s)) {
+ trailing_space = !leading_space;
+ } else {
*p++ = *s;
+ if ((!isalnum(*s) && !strchr("_-.@", *s)) ||
+ trailing_space) {
+ *p = '\0';
+ bb_error_msg("Bad address: %s", str);
+ *str = '\0';
+ return str;
+ }
+ leading_space = 0;
}
s++;
}
@@ -106,6 +119,8 @@ static char *sane_address(char *str)
static void rcptto(const char *s)
{
+ if (!*s)
+ return;
// N.B. we don't die if recipient is rejected, for the other recipients may be accepted
if (250 != smtp_checkp("RCPT TO:<%s>", s, -1))
bb_error_msg("Bad recipient: <%s>", s);