From fc4e7b69e3f764d3a1d9157868bc6965ef1db7d6 Mon Sep 17 00:00:00 2001 From: gshapiro Date: Wed, 26 Jun 2002 02:48:44 +0000 Subject: Import sendmail 8.12.5 --- contrib/sendmail/src/Makefile.m4 | 1 + contrib/sendmail/src/README | 38 +++++++++++++++++++++---- contrib/sendmail/src/aliases | 3 +- contrib/sendmail/src/bf.c | 7 +++-- contrib/sendmail/src/conf.c | 4 +-- contrib/sendmail/src/conf.h | 2 +- contrib/sendmail/src/daemon.c | 59 +++++++++++++++++++++++++++++++++++---- contrib/sendmail/src/deliver.c | 4 +-- contrib/sendmail/src/main.c | 26 +++++++++++------ contrib/sendmail/src/map.c | 3 +- contrib/sendmail/src/milter.c | 8 +++++- contrib/sendmail/src/parseaddr.c | 8 +++--- contrib/sendmail/src/queue.c | 6 ++-- contrib/sendmail/src/readcf.c | 7 ++--- contrib/sendmail/src/sasl.c | 8 +++--- contrib/sendmail/src/sendmail.h | 3 +- contrib/sendmail/src/sfsasl.c | 4 +-- contrib/sendmail/src/sm_resolve.c | 58 ++++++++++++++++++++++++++++++-------- contrib/sendmail/src/srvrsmtp.c | 5 ++-- contrib/sendmail/src/util.c | 36 +++++++++++++++++++++++- contrib/sendmail/src/version.c | 4 +-- 21 files changed, 231 insertions(+), 63 deletions(-) (limited to 'contrib/sendmail/src') diff --git a/contrib/sendmail/src/Makefile.m4 b/contrib/sendmail/src/Makefile.m4 index bb5dc1a..615ac59 100644 --- a/contrib/sendmail/src/Makefile.m4 +++ b/contrib/sendmail/src/Makefile.m4 @@ -1,3 +1,4 @@ +dnl $Id: Makefile.m4,v 8.91.2.1 2002/06/21 21:58:47 ca Exp $ include(confBUILDTOOLSDIR`/M4/switch.m4') define(`confREQUIRE_LIBSM', `true') diff --git a/contrib/sendmail/src/README b/contrib/sendmail/src/README index d24e47b..b8c31ec 100644 --- a/contrib/sendmail/src/README +++ b/contrib/sendmail/src/README @@ -9,7 +9,7 @@ # the sendmail distribution. # # -# $Id: README,v 8.355 2002/05/22 19:46:26 gshapiro Exp $ +# $Id: README,v 8.355.2.3 2002/06/21 22:44:56 gshapiro Exp $ # This directory contains the source files for sendmail(TM). @@ -1266,9 +1266,15 @@ HP-UX 8.00 README file for the future... Linux - Something broke between versions 0.99.13 and 0.99.14 of Linux: - the flock() system call gives errors. If you are running .14, - you must not use flock. You can do this with -DHASFLOCK=0. + Something broke between versions 0.99.13 and 0.99.14 of Linux: the + flock() system call gives errors. If you are running .14, you must + not use flock. You can do this with -DHASFLOCK=0. We have also + been getting complaints since version 2.4.X was released. Unless + the bug is fixed before sendmail 8.13 is shipped, 8.13 will change + the default locking method to fcntl() for Linux kernel version 2.4 + and later. Be sure to update other sendmail related programs to + match locking techniques (some examples, besides makemap and + mail.local, include procmail, mailx, mutt, elm, etc). Around the inclusion of bind-4.9.3 & Linux libc-4.6.20, the initialization of the _res structure changed. If /etc/hosts.conf @@ -1515,6 +1521,28 @@ Darwin/Mac OS X (10.X.X) b. Set / to group unwritable (as superuser): chmod g-w / +Darwin/Mac OS X (10.1.5) + Apple's upgrade to sendmail 8.12 is incorrectly configured. You + will need to manually fix it up by doing the following: + + 1. chown smmsp:smmsp /var/spool/clientmqueue + 2. chmod 2770 /var/spool/clientmqueue + 3. chgrp smmsp /usr/sbin/sendmail + 4. chmod g+s /usr/sbin/sendmail + + From Daniel J. Luke : + + It appears that setting the sendmail.cf property in + /locations/sendmail in NetInfo on Mac OS X 10.1.5 with sendmail + 8.12.4 causes 'bad things' to happen. + + Specifically sendmail instances that should be getting their config + from /etc/mail/submit.cf don't (so mail/mutt/perl scripts which + open pipes to sendmail stop working as sendmail tries to write to + /var/spool/mqueue and cannot as sendmail is no longer suid root). + + Removing the entry from NetInfo fixes this problem. + GNU getopt I'm told that GNU getopt has a problem in that it gets confused by the double call. Use the version in conf.c instead. @@ -1740,4 +1768,4 @@ util.c Some general purpose routines used by sendmail. version.c The version number and information about this version of sendmail. -(Version $Revision: 8.355 $, last update $Date: 2002/05/22 19:46:26 $ ) +(Version $Revision: 8.355.2.3 $, last update $Date: 2002/06/21 22:44:56 $ ) diff --git a/contrib/sendmail/src/aliases b/contrib/sendmail/src/aliases index 73899d4..2d06ae3 100644 --- a/contrib/sendmail/src/aliases +++ b/contrib/sendmail/src/aliases @@ -1,5 +1,5 @@ # -# $Id: aliases,v 8.4 2001/12/30 04:46:23 gshapiro Exp $ +# $Id: aliases,v 8.5 2002/06/05 22:54:26 gshapiro Exp $ # @(#)aliases 8.2 (Berkeley) 3/5/94 # # Aliases in this file will NOT be expanded in the header from @@ -35,7 +35,6 @@ ingres: root nobody: root system: root toor: root -uucp: root # Well-known aliases manager: root diff --git a/contrib/sendmail/src/bf.c b/contrib/sendmail/src/bf.c index eb41798..f678308 100644 --- a/contrib/sendmail/src/bf.c +++ b/contrib/sendmail/src/bf.c @@ -18,7 +18,7 @@ */ #include -SM_RCSID("@(#)$Id: bf.c,v 8.54 2002/04/20 18:03:42 gshapiro Exp $") +SM_RCSID("@(#)$Id: bf.c,v 8.54.2.2 2002/06/21 19:58:40 gshapiro Exp $") #include #include @@ -681,6 +681,7 @@ sm_bfcommit(fp) /* Do we need to open a file? */ if (!bfp->bf_ondisk) { + int save_errno; MODE_T omask; struct stat st; @@ -700,14 +701,16 @@ sm_bfcommit(fp) /* Clear umask as bf_filemode are the true perms */ omask = umask(0); - retval = OPEN(bfp->bf_filename, O_RDWR | O_CREAT | O_TRUNC, + retval = OPEN(bfp->bf_filename, O_RDWR | O_CREAT | O_EXCL, bfp->bf_filemode, bfp->bf_flags); + save_errno = errno; (void) umask(omask); /* Couldn't create file: failure */ if (retval < 0) { /* errno is set implicitly by open() */ + errno = save_errno; return -1; } diff --git a/contrib/sendmail/src/conf.c b/contrib/sendmail/src/conf.c index 4a0a25d..59e485b 100644 --- a/contrib/sendmail/src/conf.c +++ b/contrib/sendmail/src/conf.c @@ -13,7 +13,7 @@ #include -SM_RCSID("@(#)$Id: conf.c,v 8.969 2002/05/24 23:48:55 gshapiro Exp $") +SM_RCSID("@(#)$Id: conf.c,v 8.972 2002/06/18 16:11:44 ca Exp $") #include @@ -2338,7 +2338,7 @@ typedef unsigned int *pt_entry_t; */ # ifdef SPT_ALIGN_SIZE -# define SPT_ALIGN(x, align) ((((x) + SPT_ALIGN_SIZE) >> (align)) << (align)) +# define SPT_ALIGN(x, align) (((((x) + SPT_ALIGN_SIZE) >> (align)) << (align)) - 1) # else /* SPT_ALIGN_SIZE */ # define SPT_ALIGN(x, align) (x) # endif /* SPT_ALIGN_SIZE */ diff --git a/contrib/sendmail/src/conf.h b/contrib/sendmail/src/conf.h index 89bdd7e..22d7737 100644 --- a/contrib/sendmail/src/conf.h +++ b/contrib/sendmail/src/conf.h @@ -10,7 +10,7 @@ * the sendmail distribution. * * - * $Id: conf.h,v 8.562 2002/05/22 19:46:26 gshapiro Exp $ + * $Id: conf.h,v 8.563 2002/06/04 02:13:50 geir Exp $ */ /* diff --git a/contrib/sendmail/src/daemon.c b/contrib/sendmail/src/daemon.c index 0b2cd94..28e96ff 100644 --- a/contrib/sendmail/src/daemon.c +++ b/contrib/sendmail/src/daemon.c @@ -13,7 +13,7 @@ #include -SM_RCSID("@(#)$Id: daemon.c,v 8.612 2002/05/02 19:40:52 ca Exp $") +SM_RCSID("@(#)$Id: daemon.c,v 8.613 2002/06/05 21:26:35 gshapiro Exp $") #if defined(SOCK_STREAM) || defined(__GNU_LIBRARY__) # define USE_SOCK_STREAM 1 @@ -1710,6 +1710,58 @@ setsockaddroptions(p, d) #define DEF_LISTENQUEUE 10 +struct dflags +{ + char *d_name; + int d_flag; +}; + +static struct dflags DaemonFlags[] = +{ + { "AUTHREQ", D_AUTHREQ }, + { "BINDIF", D_BINDIF }, + { "CANONREQ", D_CANONREQ }, + { "IFNHELO", D_IFNHELO }, + { "FQMAIL", D_FQMAIL }, + { "FQRCPT", D_FQRCPT }, +#if _FFR_SMTP_SSL + { "SMTPS", D_SMTPS }, +#endif /* _FFR_SMTP_SSL */ + { "UNQUALOK", D_UNQUALOK }, + { "NOAUTH", D_NOAUTH }, + { "NOCANON", D_NOCANON }, + { "NOETRN", D_NOETRN }, + { "NOTLS", D_NOTLS }, + { "ETRNONLY", D_ETRNONLY }, + { "OPTIONAL", D_OPTIONAL }, + { "DISABLE", D_DISABLE }, + { "ISSET", D_ISSET }, + { NULL, 0 } +}; + +static void +printdaemonflags(d) + DAEMON_T *d; +{ + register struct dflags *df; + bool first = true; + + for (df = DaemonFlags; df->d_name != NULL; df++) + { + if (!bitnset(df->d_flag, d->d_flags)) + continue; + if (first) + (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "<%s", + df->d_name); + else + (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, ",%s", + df->d_name); + first = false; + } + if (!first) + (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, ">"); +} + bool setdaemonoptions(p) register char *p; @@ -1741,10 +1793,7 @@ setdaemonoptions(p) if (tTd(37, 1)) { sm_dprintf("Daemon %s flags: ", Daemons[NDaemons].d_name); - if (bitnset(D_ETRNONLY, Daemons[NDaemons].d_flags)) - sm_dprintf("ETRNONLY "); - if (bitnset(D_NOETRN, Daemons[NDaemons].d_flags)) - sm_dprintf("NOETRN "); + printdaemonflags(&Daemons[NDaemons]); sm_dprintf("\n"); } ++NDaemons; diff --git a/contrib/sendmail/src/deliver.c b/contrib/sendmail/src/deliver.c index 2b1fc4c..e70e1da 100644 --- a/contrib/sendmail/src/deliver.c +++ b/contrib/sendmail/src/deliver.c @@ -14,7 +14,7 @@ #include #include -SM_RCSID("@(#)$Id: deliver.c,v 8.939 2002/05/25 00:46:00 gshapiro Exp $") +SM_RCSID("@(#)$Id: deliver.c,v 8.940 2002/06/06 00:03:16 gshapiro Exp $") #if HASSETUSERCONTEXT # include @@ -3282,7 +3282,7 @@ do_transfer: if (i != EX_OK) { markfailure(e, to, mci, i, false); - giveresponse(i, to->q_status, m, mci, + giveresponse(i, to->q_status, m, mci, ctladdr, xstart, e, to); if (i == EX_TEMPFAIL) to->q_state = QS_RETRY; diff --git a/contrib/sendmail/src/main.c b/contrib/sendmail/src/main.c index 78c1862..22a1aac 100644 --- a/contrib/sendmail/src/main.c +++ b/contrib/sendmail/src/main.c @@ -25,7 +25,7 @@ SM_UNUSED(static char copyright[]) = The Regents of the University of California. All rights reserved.\n"; #endif /* ! lint */ -SM_RCSID("@(#)$Id: main.c,v 8.882 2002/05/10 16:20:55 ca Exp $") +SM_RCSID("@(#)$Id: main.c,v 8.887 2002/06/17 22:25:52 gshapiro Exp $") #if NETINET || NETINET6 @@ -1064,6 +1064,11 @@ main(argc, argv, envp) default: i = Errors; QueueIntvl = convtime(optarg, 'm'); + if (QueueIntvl < 0) + { + usrerr("Invalid -q value"); + ExitStat = EX_USAGE; + } /* check for bad conversion */ if (i < Errors) @@ -1188,14 +1193,19 @@ main(argc, argv, envp) if (bitset(SUBMIT_MTA, SubmitMode)) { - macdefine(&BlankEnvelope.e_macro, A_PERM, - macid("{daemon_flags}"), "CC f"); + /* If set daemon_flags on command line, don't reset it */ + if (macvalue(macid("{daemon_flags}"), &BlankEnvelope) == NULL) + macdefine(&BlankEnvelope.e_macro, A_PERM, + macid("{daemon_flags}"), "CC f"); } else if (OpMode == MD_DELIVER || OpMode == MD_SMTP) { SubmitMode = SUBMIT_MSA; - macdefine(&BlankEnvelope.e_macro, A_PERM, - macid("{daemon_flags}"), "c u"); + + /* If set daemon_flags on command line, don't reset it */ + if (macvalue(macid("{daemon_flags}"), &BlankEnvelope) == NULL) + macdefine(&BlankEnvelope.e_macro, A_PERM, + macid("{daemon_flags}"), "c u"); } /* @@ -2243,7 +2253,7 @@ main(argc, argv, envp) ** during startup. */ - if (OpMode == MD_DAEMON || QueueIntvl != 0) + if (OpMode == MD_DAEMON || QueueIntvl > 0) { char dtype[200]; @@ -2283,7 +2293,7 @@ main(argc, argv, envp) (void) sm_strlcat(dtype, "+SMTP", sizeof dtype); DaemonPid = CurrentPid; } - if (QueueIntvl != 0) + if (QueueIntvl > 0) { (void) sm_strlcat2(dtype, queuepersistent @@ -2314,7 +2324,7 @@ main(argc, argv, envp) (void) sm_releasesignal(SIGHUP); (void) sm_signal(SIGTERM, sigterm); - if (QueueIntvl != 0) + if (QueueIntvl > 0) { (void) runqueue(true, false, queuepersistent, true); diff --git a/contrib/sendmail/src/map.c b/contrib/sendmail/src/map.c index d8570d3..f0301eb 100644 --- a/contrib/sendmail/src/map.c +++ b/contrib/sendmail/src/map.c @@ -13,7 +13,7 @@ #include -SM_RCSID("@(#)$Id: map.c,v 8.645 2002/05/24 21:07:36 gshapiro Exp $") +SM_RCSID("@(#)$Id: map.c,v 8.645.2.1 2002/06/21 20:25:23 ca Exp $") #if LDAPMAP # include @@ -1234,6 +1234,7 @@ dns_map_lookup(map, name, av, statp) # endif /* NETINET6 */ } + (void) strreplnonprt(value, 'X'); if (map_p->dns_m_type != rr->rr_type) { if (tTd(38, 40)) diff --git a/contrib/sendmail/src/milter.c b/contrib/sendmail/src/milter.c index f52a725..2e45e50 100644 --- a/contrib/sendmail/src/milter.c +++ b/contrib/sendmail/src/milter.c @@ -10,7 +10,7 @@ #include -SM_RCSID("@(#)$Id: milter.c,v 8.196 2002/04/14 03:55:07 gshapiro Exp $") +SM_RCSID("@(#)$Id: milter.c,v 8.197 2002/06/12 22:33:48 gshapiro Exp $") #if MILTER # include @@ -1401,6 +1401,12 @@ milter_set_option(name, val, sticky) if (tTd(37, 2) || tTd(64, 5)) sm_dprintf("milter_set_option(%s = %s)", name, val); + if (name == NULL) + { + syserr("milter_set_option: invalid Milter option, must specify suboption"); + return; + } + for (mo = MilterOptTab; mo->mo_name != NULL; mo++) { if (sm_strcasecmp(mo->mo_name, name) == 0) diff --git a/contrib/sendmail/src/parseaddr.c b/contrib/sendmail/src/parseaddr.c index aa0e31d..0c9d49e 100644 --- a/contrib/sendmail/src/parseaddr.c +++ b/contrib/sendmail/src/parseaddr.c @@ -13,7 +13,7 @@ #include -SM_RCSID("@(#)$Id: parseaddr.c,v 8.359 2002/03/29 16:20:47 ca Exp $") +SM_RCSID("@(#)$Id: parseaddr.c,v 8.359.2.1 2002/06/19 18:24:26 gshapiro Exp $") static void allocaddr __P((ADDRESS *, int, char *, ENVELOPE *)); static int callsubr __P((char**, int, ENVELOPE *)); @@ -1124,7 +1124,7 @@ rewrite(pvp, ruleset, reclevel, e, maxatom) ap = macvalue(rp[1], e); mlp->match_first = avp; if (tTd(21, 2)) - sm_dprintf("rewrite: LHS $&%s => \"%s\"\n", + sm_dprintf("rewrite: LHS $&{%s} => \"%s\"\n", macname(rp[1]), ap == NULL ? "(NULL)" : ap); @@ -1309,7 +1309,7 @@ rewrite(pvp, ruleset, reclevel, e, maxatom) } else { - /* $&x replacement */ + /* $&{x} replacement */ char *mval = macvalue(rp[1], e); char **xpvp; int trsize = 0; @@ -1318,7 +1318,7 @@ rewrite(pvp, ruleset, reclevel, e, maxatom) char pvpbuf[PSBUFSIZE]; if (tTd(21, 2)) - sm_dprintf("rewrite: RHS $&%s => \"%s\"\n", + sm_dprintf("rewrite: RHS $&{%s} => \"%s\"\n", macname(rp[1]), mval == NULL ? "(NULL)" : mval); if (mval == NULL || *mval == '\0') diff --git a/contrib/sendmail/src/queue.c b/contrib/sendmail/src/queue.c index 5920b1e..98096c7c 100644 --- a/contrib/sendmail/src/queue.c +++ b/contrib/sendmail/src/queue.c @@ -13,7 +13,7 @@ #include -SM_RCSID("@(#)$Id: queue.c,v 8.862 2002/05/09 23:51:53 ca Exp $") +SM_RCSID("@(#)$Id: queue.c,v 8.863.2.2 2002/06/25 21:34:31 gshapiro Exp $") #include @@ -280,7 +280,7 @@ hash_q(p, h) ** I data file's inode number ** K time of last delivery attempt ** L Solaris Content-Length: header (obsolete) -** M message (obsolete) +** M message ** N number of delivery attempts ** P message priority ** q quarantine reason (_FFR_QUARANTINE) @@ -4203,7 +4203,7 @@ readqf(e, openonly) orcpt = sm_rpool_strdup_x(e->e_rpool, &bp[1]); break; - case 'r': /* original recipient */ + case 'r': /* final recipient */ frcpt = sm_rpool_strdup_x(e->e_rpool, &bp[1]); break; diff --git a/contrib/sendmail/src/readcf.c b/contrib/sendmail/src/readcf.c index c4d0637..31810a2 100644 --- a/contrib/sendmail/src/readcf.c +++ b/contrib/sendmail/src/readcf.c @@ -13,7 +13,7 @@ #include -SM_RCSID("@(#)$Id: readcf.c,v 8.606 2002/05/09 21:09:01 ca Exp $") +SM_RCSID("@(#)$Id: readcf.c,v 8.607 2002/06/14 16:57:32 ca Exp $") #if NETINET || NETINET6 # include @@ -2949,14 +2949,13 @@ setoption(opt, val, safe, sticky, e) #if _FFR_SELECT_SHM case O_SHMKEYFILE: /* shared memory key file */ # if SM_CONF_SHM - CANONIFY(val); - ShmKeyFile = newstr(val); + SET_STRING_EXP(ShmKeyFile); # else /* SM_CONF_SHM */ (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "Warning: Option: %s requires shared memory support (-DSM_CONF_SHM)\n", OPTNAME); -# endif /* SM_CONF_SHM */ break; +# endif /* SM_CONF_SHM */ #endif /* _FFR_SELECT_SHM */ #if _FFR_MAX_FORWARD_ENTRIES diff --git a/contrib/sendmail/src/sasl.c b/contrib/sendmail/src/sasl.c index beeece2..f6aa5de 100644 --- a/contrib/sendmail/src/sasl.c +++ b/contrib/sendmail/src/sasl.c @@ -9,7 +9,7 @@ */ #include -SM_RCSID("@(#)$Id: sasl.c,v 8.18 2002/05/25 00:26:42 gshapiro Exp $") +SM_RCSID("@(#)$Id: sasl.c,v 8.19 2002/06/12 15:06:12 ca Exp $") #if SASL # include @@ -262,10 +262,10 @@ iptostring(addr, addrlen, out, outlen) errno = EINVAL; return false; } - if (inet_ntop(AF_INET, &(addr->sin.sin_addr), - hbuf, sizeof hbuf) == NULL) + if (sm_strlcpy(hbuf, inet_ntoa(addr->sin.sin_addr), sizeof(hbuf)) + >= sizeof(hbuf)) { - errno = EINVAL; + errno = ENOMEM; return false; } sm_snprintf(pbuf, sizeof pbuf, "%d", ntohs(addr->sin.sin_port)); diff --git a/contrib/sendmail/src/sendmail.h b/contrib/sendmail/src/sendmail.h index 2284bd6..544e54e 100644 --- a/contrib/sendmail/src/sendmail.h +++ b/contrib/sendmail/src/sendmail.h @@ -48,7 +48,7 @@ #ifdef _DEFINE # ifndef lint -SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.918 2002/05/23 20:01:56 gshapiro Exp $"; +SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.919.2.1 2002/06/21 20:25:22 ca Exp $"; # endif /* ! lint */ #endif /* _DEFINE */ @@ -2500,6 +2500,7 @@ extern pid_t sm_wait __P((int *)); extern bool split_by_recipient __P((ENVELOPE *e)); extern void stop_sendmail __P((void)); extern char *str2prt __P((char *)); +extern bool strreplnonprt __P((char *, int)); extern bool strcontainedin __P((bool, char *, char *)); extern int switch_map_find __P((char *, char *[], short [])); extern bool transienterror __P((int)); diff --git a/contrib/sendmail/src/sfsasl.c b/contrib/sendmail/src/sfsasl.c index cad58d2..53d7276 100644 --- a/contrib/sendmail/src/sfsasl.c +++ b/contrib/sendmail/src/sfsasl.c @@ -9,7 +9,7 @@ */ #include -SM_RCSID("@(#)$Id: sfsasl.c,v 8.90 2002/05/09 20:44:11 ca Exp $") +SM_RCSID("@(#)$Id: sfsasl.c,v 8.91 2002/06/07 00:06:27 geir Exp $") #include #include #include @@ -151,7 +151,7 @@ sasl_close(fp) /* how to deallocate a buffer allocated by SASL */ extern void sm_sasl_free __P((void *)); -# define SASL_DEALLOC(b) sm_sasl_free(b) +# define SASL_DEALLOC(b) sm_sasl_free(b) /* ** SASL_READ -- read encrypted information and decrypt it for the caller diff --git a/contrib/sendmail/src/sm_resolve.c b/contrib/sendmail/src/sm_resolve.c index e3eb77f..a6f5862 100644 --- a/contrib/sendmail/src/sm_resolve.c +++ b/contrib/sendmail/src/sm_resolve.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set @@ -46,7 +46,7 @@ # if NAMED_BIND # include "sm_resolve.h" -SM_RCSID("$Id: sm_resolve.c,v 8.24 2001/09/11 04:05:16 gshapiro Exp $") +SM_RCSID("$Id: sm_resolve.c,v 8.24.4.6 2002/06/25 04:22:41 ca Exp $") static struct stot { @@ -180,8 +180,8 @@ parse_dns_reply(data, len) p = data; /* doesn't work on Crays? */ - memcpy(&r->dns_r_h, p, sizeof(HEADER)); - p += sizeof(HEADER); + memcpy(&r->dns_r_h, p, sizeof(r->dns_r_h)); + p += sizeof(r->dns_r_h); status = dn_expand(data, data + len, p, host, sizeof host); if (status < 0) { @@ -200,7 +200,7 @@ parse_dns_reply(data, len) rr = &r->dns_r_head; while (p < data + len) { - int type, class, ttl, size; + int type, class, ttl, size, txtlen; status = dn_expand(data, data + len, p, host, sizeof host); if (status < 0) @@ -213,7 +213,21 @@ parse_dns_reply(data, len) GETSHORT(class, p); GETLONG(ttl, p); GETSHORT(size, p); - *rr = (RESOURCE_RECORD_T *) xalloc(sizeof(RESOURCE_RECORD_T)); + if (p + size > data + len) + { + /* + ** announced size of data exceeds length of + ** data paket: someone is cheating. + */ + + if (LogLevel > 5) + sm_syslog(LOG_WARNING, NOQID, + "ERROR: DNS RDLENGTH=%d > data len=%d", + size, len - (p - data)); + dns_free_data(r); + return NULL; + } + *rr = (RESOURCE_RECORD_T *) xalloc(sizeof(**rr)); if (*rr == NULL) { dns_free_data(r); @@ -260,7 +274,7 @@ parse_dns_reply(data, len) } l = strlen(host) + 1; (*rr)->rr_u.rr_mx = (MX_RECORD_T *) - xalloc(sizeof(MX_RECORD_T) + l); + xalloc(sizeof(*((*rr)->rr_u.rr_mx)) + l); if ((*rr)->rr_u.rr_mx == NULL) { dns_free_data(r); @@ -281,7 +295,7 @@ parse_dns_reply(data, len) } l = strlen(host) + 1; (*rr)->rr_u.rr_srv = (SRV_RECORDT_T*) - xalloc(sizeof(SRV_RECORDT_T) + l); + xalloc(sizeof(*((*rr)->rr_u.rr_srv)) + l); if ((*rr)->rr_u.rr_srv == NULL) { dns_free_data(r); @@ -295,14 +309,35 @@ parse_dns_reply(data, len) break; case T_TXT: - (*rr)->rr_u.rr_txt = (char *) xalloc(size + 1); + + /* + ** The TXT record contains the length as + ** leading byte, hence the value is restricted + ** to 255, which is less than the maximum value + ** of RDLENGTH (size). Nevertheless, txtlen + ** must be less than size because the latter + ** specifies the length of the entire TXT + ** record. + */ + + txtlen = *p; + if (txtlen >= size) + { + if (LogLevel > 5) + sm_syslog(LOG_WARNING, NOQID, + "ERROR: DNS TXT record size=%d <= text len=%d", + size, txtlen); + dns_free_data(r); + return NULL; + } + (*rr)->rr_u.rr_txt = (char *) xalloc(txtlen + 1); if ((*rr)->rr_u.rr_txt == NULL) { dns_free_data(r); return NULL; } - (void) strncpy((*rr)->rr_u.rr_txt, (char*) p + 1, *p); - (*rr)->rr_u.rr_txt[*p] = 0; + (void) sm_strlcpy((*rr)->rr_u.rr_txt, (char*) p + 1, + txtlen + 1); break; default: @@ -313,6 +348,7 @@ parse_dns_reply(data, len) return NULL; } (void) memcpy((*rr)->rr_u.rr_data, p, size); + break; } p += size; rr = &(*rr)->rr_next; diff --git a/contrib/sendmail/src/srvrsmtp.c b/contrib/sendmail/src/srvrsmtp.c index bbcd31f..dd14ffa 100644 --- a/contrib/sendmail/src/srvrsmtp.c +++ b/contrib/sendmail/src/srvrsmtp.c @@ -16,7 +16,7 @@ # include #endif /* MILTER */ -SM_RCSID("@(#)$Id: srvrsmtp.c,v 8.827 2002/05/28 14:29:57 ca Exp $") +SM_RCSID("@(#)$Id: srvrsmtp.c,v 8.829 2002/06/17 21:54:57 gshapiro Exp $") #if SASL || STARTTLS # include @@ -1896,7 +1896,8 @@ smtp(nullserver, d_flags, e) message("250-AUTH %s", mechlist); #endif /* SASL */ #if STARTTLS - if (tls_ok_srv && bitset(SRV_OFFER_TLS, features)) + if (tls_ok_srv && + bitset(SRV_OFFER_TLS, features)) message("250-STARTTLS"); #endif /* STARTTLS */ if (DeliverByMin > 0) diff --git a/contrib/sendmail/src/util.c b/contrib/sendmail/src/util.c index 4974541..52b37ec 100644 --- a/contrib/sendmail/src/util.c +++ b/contrib/sendmail/src/util.c @@ -13,7 +13,7 @@ #include -SM_RCSID("@(#)$Id: util.c,v 8.363 2002/05/24 20:44:05 gshapiro Exp $") +SM_RCSID("@(#)$Id: util.c,v 8.363.2.1 2002/06/21 20:25:25 ca Exp $") #include #include @@ -2239,6 +2239,40 @@ denlstring(s, strict, logattacks) return bp; } + +/* +** STRREPLNONPRT -- replace "unprintable" characters in a string with subst +** +** Parameters: +** s -- string to manipulate (in place) +** subst -- character to use as replacement +** +** Returns: +** true iff string did not contain "unprintable" characters +*/ + +bool +strreplnonprt(s, c) + char *s; + int c; +{ + bool ok; + + ok = true; + if (s == NULL) + return ok; + while (*s != '\0') + { + if (!(isascii(*s) && isprint(*s))) + { + *s = c; + ok = false; + } + ++s; + } + return ok; +} + /* ** STR2PRT -- convert "unprintable" characters in a string to \oct ** diff --git a/contrib/sendmail/src/version.c b/contrib/sendmail/src/version.c index 3e86eb0..3600b84 100644 --- a/contrib/sendmail/src/version.c +++ b/contrib/sendmail/src/version.c @@ -13,6 +13,6 @@ #include -SM_RCSID("@(#)$Id: version.c,v 8.102 2002/05/31 18:53:59 ca Exp $") +SM_RCSID("@(#)$Id: version.c,v 8.104.2.2 2002/06/25 22:51:53 ca Exp $") -char Version[] = "8.12.4"; +char Version[] = "8.12.5"; -- cgit v1.1