summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/src/recipient.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/sendmail/src/recipient.c')
-rw-r--r--contrib/sendmail/src/recipient.c76
1 files changed, 50 insertions, 26 deletions
diff --git a/contrib/sendmail/src/recipient.c b/contrib/sendmail/src/recipient.c
index d952a8b..ea30adc 100644
--- a/contrib/sendmail/src/recipient.c
+++ b/contrib/sendmail/src/recipient.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2003 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2003, 2006 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@@ -13,7 +13,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: recipient.c,v 8.337 2004/08/03 19:57:23 ca Exp $")
+SM_RCSID("@(#)$Id: recipient.c,v 8.348 2007/03/19 21:33:09 ca Exp $")
static void includetimeout __P((int));
static ADDRESS *self_reference __P((ADDRESS *));
@@ -200,10 +200,10 @@ sendtolist(list, ctladdr, sendq, aliaslevel, e)
/* make sure we have enough space to copy the string */
i = strlen(list) + 1;
- if (i <= sizeof buf)
+ if (i <= sizeof(buf))
{
bufp = buf;
- i = sizeof buf;
+ i = sizeof(buf);
}
else
bufp = sm_malloc_x(i);
@@ -309,6 +309,7 @@ sendtolist(list, ctladdr, sendq, aliaslevel, e)
SM_END_TRY
return naddrs;
}
+
#if MILTER
/*
** REMOVEFROMLIST -- Remove addresses from a send list.
@@ -364,10 +365,10 @@ removefromlist(list, sendq, e)
/* make sure we have enough space to copy the string */
i = strlen(list) + 1;
- if (i <= sizeof buf)
+ if (i <= sizeof(buf))
{
bufp = buf;
- i = sizeof buf;
+ i = sizeof(buf);
}
else
bufp = sm_malloc_x(i);
@@ -387,7 +388,7 @@ removefromlist(list, sendq, e)
/* parse the address */
while ((isascii(*p) && isspace(*p)) || *p == ',')
p++;
- if (parseaddr(p, &a, RF_COPYALL,
+ if (parseaddr(p, &a, RF_COPYALL|RF_RM_ADDR,
delimiter, &delimptr, e, true) == NULL)
{
p = delimptr;
@@ -423,10 +424,10 @@ removefromlist(list, sendq, e)
return naddrs;
}
#endif /* MILTER */
+
/*
** RECIPIENT -- Designate a message recipient
-**
-** Saves the named person for future mailing.
+** Saves the named person for future mailing (after some checks).
**
** Parameters:
** new -- the (preparsed) address header for the recipient.
@@ -503,13 +504,13 @@ recipient(new, sendq, aliaslevel, e)
p = "rfc822";
if (sm_strcasecmp(p, "rfc822") != 0)
{
- (void) sm_snprintf(frbuf, sizeof frbuf, "%s; %.800s",
+ (void) sm_snprintf(frbuf, sizeof(frbuf), "%s; %.800s",
q->q_mailer->m_addrtype,
q->q_user);
}
else if (strchr(q->q_user, '@') != NULL)
{
- (void) sm_snprintf(frbuf, sizeof frbuf, "%s; %.800s",
+ (void) sm_snprintf(frbuf, sizeof(frbuf), "%s; %.800s",
p, q->q_user);
}
else if (strchr(q->q_paddr, '@') != NULL)
@@ -528,7 +529,7 @@ recipient(new, sendq, aliaslevel, e)
qp[strlen(qp) - 1] = '\0';
qp++;
}
- (void) sm_snprintf(frbuf, sizeof frbuf, "%s; %.800s",
+ (void) sm_snprintf(frbuf, sizeof(frbuf), "%s; %.800s",
p, qp);
/* undo damage */
@@ -537,7 +538,7 @@ recipient(new, sendq, aliaslevel, e)
}
else
{
- (void) sm_snprintf(frbuf, sizeof frbuf,
+ (void) sm_snprintf(frbuf, sizeof(frbuf),
"%s; %.700s@%.100s",
p, q->q_user, MyHostName);
}
@@ -562,7 +563,7 @@ recipient(new, sendq, aliaslevel, e)
p = e->e_from.q_mailer->m_addrtype;
if (p == NULL)
p = "rfc822";
- (void) sm_strlcpyn(obuf, sizeof obuf, 2, p, ";");
+ (void) sm_strlcpyn(obuf, sizeof(obuf), 2, p, ";");
qp = q->q_paddr;
@@ -577,9 +578,9 @@ recipient(new, sendq, aliaslevel, e)
qp++;
}
- p = xtextify(denlstring(qp, true, false), NULL);
+ p = xtextify(denlstring(qp, true, false), "=");
- if (sm_strlcat(obuf, p, sizeof obuf) >= sizeof obuf)
+ if (sm_strlcat(obuf, p, sizeof(obuf)) >= sizeof(obuf))
{
/* if too big, don't use it */
obuf[0] = '\0';
@@ -601,6 +602,18 @@ recipient(new, sendq, aliaslevel, e)
{
new->q_state = QS_BADADDR;
new->q_status = "5.4.6";
+ if (new->q_alias != NULL)
+ {
+ new->q_alias->q_state = QS_BADADDR;
+ new->q_alias->q_status = "5.4.6";
+ }
+ if ((SuprErrs || !LogUsrErrs) && LogLevel > 0)
+ {
+ sm_syslog(LOG_ERR, e->e_id,
+ "aliasing/forwarding loop broken: %s (%d aliases deep; %d max)",
+ FileName != NULL ? FileName : "", aliaslevel,
+ MaxAliasRecursion);
+ }
usrerrenh(new->q_status,
"554 aliasing/forwarding loop broken (%d aliases deep; %d max)",
aliaslevel, MaxAliasRecursion);
@@ -613,7 +626,7 @@ recipient(new, sendq, aliaslevel, e)
/* get unquoted user for file, program or user.name check */
i = strlen(new->q_user);
- if (i >= sizeof buf0)
+ if (i >= sizeof(buf0))
{
buflen = i + 1;
buf = xalloc(buflen);
@@ -621,7 +634,7 @@ recipient(new, sendq, aliaslevel, e)
else
{
buf = buf0;
- buflen = sizeof buf0;
+ buflen = sizeof(buf0);
}
(void) sm_strlcpy(buf, new->q_user, buflen);
for (p = buf; *p != '\0' && !quoted; p++)
@@ -904,7 +917,8 @@ recipient(new, sendq, aliaslevel, e)
{
new->q_state = QS_QUEUEUP;
if (e->e_message == NULL)
- e->e_message = "Deferred: user database error";
+ e->e_message = sm_rpool_strdup_x(e->e_rpool,
+ "Deferred: user database error");
if (new->q_message == NULL)
new->q_message = "Deferred: user database error";
if (LogLevel > 8)
@@ -1106,10 +1120,11 @@ recipient(new, sendq, aliaslevel, e)
}
}
new->q_flags |= QRCPTOK;
- (void) sm_snprintf(buf0, sizeof buf0, "%d", e->e_nrcpts);
+ (void) sm_snprintf(buf0, sizeof(buf0), "%d", e->e_nrcpts);
macdefine(&e->e_macro, A_TEMP, macid("{nrcpts}"), buf0);
return new;
}
+
/*
** FINDUSER -- find the password entry for a user.
**
@@ -1222,7 +1237,7 @@ finduser(name, fuzzyp, user)
}
# endif /* 0 */
- sm_pwfullname(pw->pw_gecos, pw->pw_name, buf, sizeof buf);
+ sm_pwfullname(pw->pw_gecos, pw->pw_name, buf, sizeof(buf));
if (strchr(buf, ' ') != NULL && sm_strcasecmp(buf, name) == 0)
{
if (tTd(29, 4))
@@ -1248,6 +1263,7 @@ finduser(name, fuzzyp, user)
return EX_NOUSER;
#endif /* MATCHGECOS */
}
+
/*
** WRITABLE -- predicate returning if the file is writable.
**
@@ -1351,6 +1367,7 @@ writable(filename, ctladdr, flags)
errno = safefile(filename, euid, egid, user, flags, S_IWRITE, NULL);
return errno == 0;
}
+
/*
** INCLUDE -- handle :include: specification.
**
@@ -1801,7 +1818,7 @@ resetuid:
LineNumber = 0;
ctladdr->q_flags &= ~QSELFREF;
nincludes = 0;
- while (sm_io_fgets(fp, SM_TIME_DEFAULT, buf, sizeof buf) != NULL &&
+ while (sm_io_fgets(fp, SM_TIME_DEFAULT, buf, sizeof(buf)) != NULL &&
!maxreached)
{
fixcrlf(buf, true);
@@ -1858,12 +1875,16 @@ resetuid:
sm_dprintf("include: read error: %s\n", sm_errstring(errno));
if (nincludes > 0 && !bitset(QSELFREF, ctladdr->q_flags))
{
- if (tTd(27, 5))
+ if (aliaslevel <= MaxAliasRecursion ||
+ ctladdr->q_state != QS_BADADDR)
{
- sm_dprintf("include: QS_DONTSEND ");
- printaddr(sm_debug_file(), ctladdr, false);
+ ctladdr->q_state = QS_DONTSEND;
+ if (tTd(27, 5))
+ {
+ sm_dprintf("include: QS_DONTSEND ");
+ printaddr(sm_debug_file(), ctladdr, false);
+ }
}
- ctladdr->q_state = QS_DONTSEND;
}
(void) sm_io_close(fp, SM_TIME_DEFAULT);
@@ -1886,6 +1907,7 @@ includetimeout(ignore)
errno = ETIMEDOUT;
longjmp(CtxIncludeTimeout, 1);
}
+
/*
** SENDTOARGV -- send to an argument vector.
**
@@ -1911,6 +1933,7 @@ sendtoargv(argv, e)
while ((p = *argv++) != NULL)
(void) sendtolist(p, NULLADDR, &e->e_sendqueue, 0, e);
}
+
/*
** GETCTLADDR -- get controlling address from an address header.
**
@@ -1931,6 +1954,7 @@ getctladdr(a)
a = a->q_alias;
return a;
}
+
/*
** SELF_REFERENCE -- check to see if an address references itself
**
OpenPOWER on IntegriCloud