SCCS-vsn: usr.sbin/sendmail/src/domain.c 6.23
/*
* Copyright (c) 1986 Eric P. Allman
/*
* Copyright (c) 1986 Eric P. Allman
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
*
* %sccs.include.redist.c%
*/
*
* %sccs.include.redist.c%
*/
#ifndef lint
#ifdef NAMED_BIND
#ifndef lint
#ifdef NAMED_BIND
-static char sccsid[] = "@(#)domain.c 6.22 (Berkeley) %G% (with name server)";
+static char sccsid[] = "@(#)domain.c 6.23 (Berkeley) %G% (with name server)";
-static char sccsid[] = "@(#)domain.c 6.22 (Berkeley) %G% (without name server)";
+static char sccsid[] = "@(#)domain.c 6.23 (Berkeley) %G% (without name server)";
#endif
#endif /* not lint */
#endif
#endif /* not lint */
/* don't use sizeof because sizeof(long) is different on 64-bit machines */
#define SHORTSIZE 2 /* size of a short (really, must be 2) */
#define LONGSIZE 4 /* size of a long (really, must be 4) */
/* don't use sizeof because sizeof(long) is different on 64-bit machines */
#define SHORTSIZE 2 /* size of a short (really, must be 2) */
#define LONGSIZE 4 /* size of a long (really, must be 4) */
+
+#define MAXCNAMEDEPTH 10 /* maximum depth of CNAME recursion */
\f/*
** GETMXRR -- get MX resource records for a domain
**
\f/*
** GETMXRR -- get MX resource records for a domain
**
bool amatch;
bool gotmx;
int qtype;
bool amatch;
bool gotmx;
int qtype;
char nbuf[MAX(PACKETSZ, MAXDNAME*2+2)];
char *searchlist[MAXDNSRCH+2];
char nbuf[MAX(PACKETSZ, MAXDNAME*2+2)];
char *searchlist[MAXDNSRCH+2];
** list by tearing apart the host name.
*/
** list by tearing apart the host name.
*/
cnameloop:
for (cp = host, n = 0; *cp; cp++)
if (*cp == '.')
cnameloop:
for (cp = host, n = 0; *cp; cp++)
if (*cp == '.')
+ if (loopcnt++ > MAXCNAMEDEPTH)
+ {
+ syserr("DNS failure: CNAME loop for %s",
+ host);
+ continue;
+ }
+
/* value points at name */
if ((ret = dn_expand((u_char *)&answer,
eom, ap, (u_char *)nbuf, sizeof(nbuf))) < 0)
/* value points at name */
if ((ret = dn_expand((u_char *)&answer,
eom, ap, (u_char *)nbuf, sizeof(nbuf))) < 0)