Subject: sendmail security fix ported from 8.6.10 (#230) Index: usr.lib/sendmail/src/many 2.11BSD Description: Recently there was a CERT advisory concerning another security problem in sendmail. The solution was to upgrade from sendmail 8.6.9 to 8.6.10. Since running V8 is not an option for 2.11BSD the alternate solution of porting the security fix to V5 was adopted instead. Repeat-By: Inspection. Fix: This fix was derived from the 8.6.9 to 8.6.10 patch. The \n and "clean string copy" routines were ported directly from 8.6.10. At the same time the 'arpadate.c' routine was replaced with the one from 8.6.10. By using only the numeric timezone format the timezone string conversion table(s) were removed, saving 90+ bytes of D space. The Makefile.m4 file was also updated because the overlay structure changed. To apply this update: 1) Save the following to a file (/tmp/230) 2) patch -p0 < /tmp/230 3) cd /usr/src/usr.lib/sendmail/src m4 < Makefile.m4 > Makefile make 4) Kill the currently running sendmail process. 5) make install /usr/lib/sendmail -bz make clean 6) Restart the sendmail process. If you are running sendmail from inetd then nothing more needs to be done at this point. If you are not running sendmail from inetd then you will need to do something like: /usr/lib/sendmail -bd -q20m or whatever queuerun time you prefer. This and all previous updates to 2.11BSD are available via anonymous FTP to the host "ftp.iipo.gtegsc.com" in the directory /pub/2.11BSD. =====================cut here=============== *** /usr/src/usr.lib/sendmail/src/Makefile.m4.old Mon Jan 30 21:16:08 1995 --- /usr/src/usr.lib/sendmail/src/Makefile.m4 Thu Mar 9 19:58:17 1995 *************** *** 7,13 **** # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile.m4 5.10.2 (2.11BSD GTE) 1/30/95 # # # SENDMAIL Makefile. --- 7,13 ---- # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile.m4 5.10.3 (2.11BSD GTE) 3/07/95 # # # SENDMAIL Makefile. *************** *** 33,40 **** SBASE= conf.o collect.o parseaddr.o alias.o deliver.o headers.o \ recipient.o srvrsmtp.o queue.o util.o \ envelope.o sysexits.o arpadate.o convtime.o Version.o \ ! ctime.o $(EXTRACT) str.o ! SOV1= main.o readcf.o macro.o SOV2= daemon.o savemail.o usersmtp.o err.o clock.o stats.o trace.o stab.o SRCS= \ --- 33,40 ---- SBASE= conf.o collect.o parseaddr.o alias.o deliver.o headers.o \ recipient.o srvrsmtp.o queue.o util.o \ envelope.o sysexits.o arpadate.o convtime.o Version.o \ ! $(EXTRACT) str.o ! SOV1= main.o readcf.o macro.o ctime.o SOV2= daemon.o savemail.o usersmtp.o err.o clock.o stats.o trace.o stab.o SRCS= \ *************** *** 81,86 **** --- 81,91 ---- fi install -c -s -o bin -m 0755 ctimed $(DESTDIR)/usr/lib/ctimed + tags: FRC + ctags -a -t ${SRCS} + + FRC: + $(OBJS1): sendmail.h $(OBJS): conf.h stats.o: mailstats.h *************** *** 92,99 **** # clean: ! rm -f core sendmail rmail usersmtp uucp a.out XREF sendmail.cf ! rm -f sendmail.sr *.o ctimed strings version.c print: $(SRCS) @ls -l | pr -h "sendmail directory" --- 97,104 ---- # clean: ! rm -f sendmail a.out XREF sendmail.cf ! rm -f sendmail.sr *.o ctimed strings version.c xs.c print: $(SRCS) @ls -l | pr -h "sendmail directory" *** /usr/src/usr.lib/sendmail/src/arpadate.c.old Wed Feb 10 15:26:08 1988 --- /usr/src/usr.lib/sendmail/src/arpadate.c Tue Mar 7 23:12:24 1995 *************** *** 1,36 **** /* ! ** Sendmail ! ** Copyright (c) 1983 Eric P. Allman ! ** Berkeley, California ! ** ! ** Copyright (c) 1983 Regents of the University of California. ! ** All rights reserved. The Berkeley software License Agreement ! ** specifies the terms and conditions for redistribution. ! */ ! #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)arpadate.c 5.5 (Berkeley) 3/18/87"; #endif ! # include "conf.h" ! # ifdef USG ! # include ! # else ! # include ! # ifndef V6 ! # include ! # include ! # endif V6 ! # endif USG ! # include "useful.h" - # ifdef V6 - # define OLDTIME - # endif V6 - # ifdef USG - # define OLDTIME - # endif USG - /* ** ARPADATE -- Create date in ARPANET format ** --- 1,44 ---- /* ! * Copyright (c) 1983 Eric P. Allman ! * Copyright (c) 1988, 1993 ! * The Regents of the University of California. All rights reserved. ! * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in the ! * documentation and/or other materials provided with the distribution. ! * 3. All advertising materials mentioning features or use of this software ! * must display the following acknowledgement: ! * This product includes software developed by the University of ! * California, Berkeley and its contributors. ! * 4. Neither the name of the University nor the names of its contributors ! * may be used to endorse or promote products derived from this software ! * without specific prior written permission. ! * ! * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! * SUCH DAMAGE. ! */ ! #if !defined(lint) && !defined(NOSCCS) ! static char sccsid[] = "@(#)arpadate.c 8.1.1 (2.11BSD GTE) 3/7/95"; #endif ! #include "sendmail.h" ! #include /* ** ARPADATE -- Create date in ARPANET format ** *************** *** 59,86 **** char * arpadate(ud) ! register char *ud; { register char *p; register char *q; static char b[40]; - extern char *ctime(); - register int i; - extern struct tm *localtime(); - extern bool fconvert(); - # ifdef OLDTIME - long t; - extern long time(); - # else OLDTIME - struct timeb t; - extern struct timeb *ftime(); - # endif OLDTIME - # ifdef V6 - extern char *StdTimezone, *DstTimezone; - # endif V6 - # ifdef USG - extern char *tzname[2]; - # endif USG /* ** Get current time. --- 67,82 ---- char * arpadate(ud) ! char *ud; { register char *p; register char *q; + int off; + int i; + register struct tm *lt; + time_t t; + struct tm gmt; static char b[40]; /* ** Get current time. *************** *** 88,102 **** ** to resolve the timezone. */ - # ifdef OLDTIME (void) time(&t); if (ud == NULL) ud = ctime(&t); - # else - ftime(&t); - if (ud == NULL) - ud = ctime(&t.time); - # endif OLDTIME /* ** Crack the UNIX date line in a singularly unoriginal way. --- 84,92 ---- *************** *** 125,133 **** *q++ = *p++; *q++ = ' '; ! p = &ud[22]; /* 79 */ *q++ = *p++; *q++ = *p++; *q++ = ' '; p = &ud[11]; /* 01:03:52 */ --- 115,125 ---- *q++ = *p++; *q++ = ' '; ! p = &ud[20]; /* 1979 */ *q++ = *p++; *q++ = *p++; + *q++ = *p++; + *q++ = *p++; *q++ = ' '; p = &ud[11]; /* 01:03:52 */ *************** *** 134,238 **** for (i = 8; i > 0; i--) *q++ = *p++; ! /* -PST or -PDT */ ! # ifdef V6 ! if (localtime(&t)->tm_isdst) ! p = DstTimezone; ! else ! p = StdTimezone; ! # else ! # ifdef USG ! if (localtime(&t)->tm_isdst) ! p = tzname[1]; ! else ! p = tzname[0]; ! # else ! p = localtime(&t.time)->tm_zone; ! # endif USG ! # endif V6 ! if ((strncmp(p, "GMT", 3) == 0 || strncmp(p, "gmt", 3) == 0) && ! p[3] != '\0') ! { ! /* hours from GMT */ ! p += 3; ! *q++ = *p++; ! if (p[1] == ':') ! *q++ = '0'; ! else ! *q++ = *p++; ! *q++ = *p++; ! p++; /* skip ``:'' */ ! *q++ = *p++; ! *q++ = *p++; ! *q = '\0'; ! } ! else if (!fconvert(p, q)) ! { ! *q++ = ' '; ! *q++ = *p++; ! *q++ = *p++; ! *q++ = *p++; ! *q = '\0'; ! } ! return (b); ! } ! /* ! ** FCONVERT -- convert foreign timezones to ARPA timezones ! ** ! ** This routine is essentially from Teus Hagen. ! ** ! ** Parameters: ! ** a -- timezone as returned from UNIX. ! ** b -- place to put ARPA-style timezone. ! ** ! ** Returns: ! ** TRUE -- if a conversion was made (and b was filled in). ! ** FALSE -- if this is not a recognized local time. ! ** ! ** Side Effects: ! ** none. ! */ ! /* UNIX to arpa conversion table */ ! struct foreign ! { ! char *f_from; ! char *f_to; ! }; ! static struct foreign Foreign[] = ! { ! { "EET", "+0200" }, /* eastern europe */ ! { "MET", "+0100" }, /* middle europe */ ! { "WET", "GMT" }, /* western europe */ ! { "EET DST", "+0300" }, /* daylight saving times */ ! { "MET DST", "+0200" }, ! { "WET DST", "+0100" }, ! { NULL, NULL } ! }; ! bool ! fconvert(a, b) ! register char *a; ! char *b; ! { ! register struct foreign *euptr; ! register char *p; ! for (euptr = Foreign; euptr->f_from != NULL; euptr++) ! { ! extern bool sameword(); ! ! if (sameword(euptr->f_from, a)) ! { ! p = euptr->f_to; ! *b++ = ' '; ! while (*p != '\0') ! *b++ = *p++; ! *b = '\0'; ! return (TRUE); ! } } ! return (FALSE); } --- 126,174 ---- for (i = 8; i > 0; i--) *q++ = *p++; ! /* ! * should really get the timezone from the time in "ud" (which ! * is only different if a non-null arg was passed which is different ! * from the current time), but for all practical purposes, returning ! * the current local zone will do (its all that is ever needed). ! */ ! gmt = *gmtime(&t); ! lt = localtime(&t); ! off = (lt->tm_hour - gmt.tm_hour) * 60 + lt->tm_min - gmt.tm_min; ! /* assume that offset isn't more than a day ... */ ! if (lt->tm_year < gmt.tm_year) ! off -= 24 * 60; ! else if (lt->tm_year > gmt.tm_year) ! off += 24 * 60; ! else if (lt->tm_yday < gmt.tm_yday) ! off -= 24 * 60; ! else if (lt->tm_yday > gmt.tm_yday) ! off += 24 * 60; ! *q++ = ' '; ! if (off == 0) { ! *q++ = 'G'; ! *q++ = 'M'; ! *q++ = 'T'; ! } else { ! if (off < 0) { ! off = -off; ! *q++ = '-'; ! } else ! *q++ = '+'; ! if (off >= 24*60) /* should be impossible */ ! off = 23*60+59; /* if not, insert silly value */ ! *q++ = (off / 600) + '0'; ! *q++ = (off / 60) % 10 + '0'; ! off %= 60; ! *q++ = (off / 10) + '0'; ! *q++ = (off % 10) + '0'; } ! *q = '\0'; ! ! return (b); } *** /usr/src/usr.lib/sendmail/src/deliver.c.old Mon Oct 10 20:26:02 1988 --- /usr/src/usr.lib/sendmail/src/deliver.c Mon Mar 6 22:09:12 1995 *************** *** 9,15 **** */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)deliver.c 5.10 (Berkeley) 3/2/86"; #endif # include --- 9,15 ---- */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)deliver.c 5.10.1 (2.11BSD GTE) 3/6/95"; #endif # include *************** *** 988,995 **** message(Arpa_Info, &statmsg[4]); else { Errors++; ! usrerr(statmsg); } /* --- 988,998 ---- message(Arpa_Info, &statmsg[4]); else { + char mbuf[8]; + Errors++; ! sprintf(mbuf, "%.3s %%s", statmsg); ! usrerr(mbuf, &statmsg[4]); } /* *************** *** 1280,1296 **** register ADDRESS *q; bool oldverbose; int pid; /* determine actual delivery mode */ if (mode == SM_DEFAULT) { - extern bool shouldqueue(); - if (shouldqueue(e->e_msgpriority)) mode = SM_QUEUE; ! else ! mode = SendMode; } #ifdef DEBUG if (tTd(13, 1)) --- 1283,1299 ---- register ADDRESS *q; bool oldverbose; int pid; + bool announcequeueup; /* determine actual delivery mode */ if (mode == SM_DEFAULT) { if (shouldqueue(e->e_msgpriority)) mode = SM_QUEUE; ! announcequeueup = mode == SendMode; } + else + announcequeueup = FALSE; #ifdef DEBUG if (tTd(13, 1)) *************** *** 1310,1316 **** if (e->e_hopcount > MAXHOP) { ! syserr("sendall: too many hops (%d max)", MAXHOP); return; } --- 1313,1325 ---- if (e->e_hopcount > MAXHOP) { ! errno = 0; ! queueup(e, TRUE, announcequeueup); ! e->e_flags |= EF_FATALERRS|EF_CLRQUEUE; ! syserr("too many hops (%d max): from %s via %s, to %s", ! MAXHOP, e->e_from.q_paddr, ! RealHostName == NULL ? "localhost" : RealHostName, ! e->e_sendqueue->q_paddr); return; } *************** *** 1326,1332 **** if ((mode == SM_QUEUE || mode == SM_FORK || (mode != SM_VERIFY && SuperSafe)) && !bitset(EF_INQUEUE, e->e_flags)) ! queueup(e, TRUE, mode == SM_QUEUE); #endif QUEUE oldverbose = Verbose; --- 1335,1341 ---- if ((mode == SM_QUEUE || mode == SM_FORK || (mode != SM_VERIFY && SuperSafe)) && !bitset(EF_INQUEUE, e->e_flags)) ! queueup(e, TRUE, announcequeueup); #endif QUEUE oldverbose = Verbose; *** /usr/src/usr.lib/sendmail/src/main.c.old Fri Jul 15 14:25:16 1994 --- /usr/src/usr.lib/sendmail/src/main.c Mon Mar 6 23:02:31 1995 *************** *** 13,19 **** "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; ! static char SccsId[] = "@(#)main.c 5.11.1 (2.11BSD GTE) 7/15/94"; #endif # define _DEFINE --- 13,19 ---- "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; ! static char SccsId[] = "@(#)main.c 5.11.2 (2.11BSD GTE) 3/6/95"; #endif # define _DEFINE *************** *** 225,233 **** OldUmask = umask(0); OpMode = MD_DELIVER; MotherPid = getpid(); - # ifndef V6 FullName = getenv("NAME"); - # endif V6 # ifdef LOG openlog("sendmail", LOG_PID, LOG_MAIL); --- 225,231 ---- *************** *** 344,350 **** syserr("More than one \"from\" person"); break; } ! from = newstr(p); break; case 'F': /* set full name */ --- 342,348 ---- syserr("More than one \"from\" person"); break; } ! from = newstr(denlstring(p)); break; case 'F': /* set full name */ *************** *** 379,384 **** --- 377,383 ---- case 'q': /* run queue files at intervals */ # ifdef QUEUE + FullName = NULL; queuemode = TRUE; QueueIntvl = convtime(&p[2]); # else QUEUE *************** *** 435,441 **** --- 434,449 ---- case MD_INITALIAS: Verbose = TRUE; break; + + case MD_DAEMON: + /* remove things that don't make sense in daemon mode */ + FullName = NULL; + break; } + + /* full names can't have newlines */ + if (FullName != NULL && strchr(FullName, '\n') != NULL) + FullName = newstr(denlstring(FullName)); /* do heuristic mode adjustment */ if (Verbose) *** /usr/src/usr.lib/sendmail/src/queue.c.old Wed Feb 10 15:26:23 1988 --- /usr/src/usr.lib/sendmail/src/queue.c Tue Mar 7 21:24:55 1995 *************** *** 15,30 **** # include # include - # ifndef QUEUE #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)queue.c 5.21 (Berkeley) 4/17/86 (no queueing)"; ! # endif ! # else QUEUE ! #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)queue.c 5.21 (Berkeley) 4/17/86"; ! # endif ! /* ** Work queue. */ --- 15,25 ---- # include # include #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)queue.c 5.21.1 (2.11BSD GTE) 3/07/95"; ! #endif ! #ifdef QUEUE /* ** Work queue. */ *************** *** 127,136 **** /* message from envelope, if it exists */ if (e->e_message != NULL) ! fprintf(tfp, "M%s\n", e->e_message); /* output name of sender */ ! fprintf(tfp, "S%s\n", e->e_from.q_paddr); /* output list of recipient addresses */ for (q = e->e_sendqueue; q != NULL; q = q->q_next) --- 122,131 ---- /* message from envelope, if it exists */ if (e->e_message != NULL) ! fprintf(tfp, "M%s\n", denlstring(e->e_message)); /* output name of sender */ ! fprintf(tfp, "S%s\n", denlstring(e->e_from.q_paddr)); /* output list of recipient addresses */ for (q = e->e_sendqueue; q != NULL; q = q->q_next) *************** *** 138,144 **** if (queueall ? !bitset(QDONTSEND, q->q_flags) : bitset(QQUEUEUP, q->q_flags)) { ! fprintf(tfp, "R%s\n", q->q_paddr); if (announce) { e->e_to = q->q_paddr; --- 133,139 ---- if (queueall ? !bitset(QDONTSEND, q->q_flags) : bitset(QQUEUEUP, q->q_flags)) { ! fprintf(tfp, "R%s\n", denlstring(q->q_paddr)); if (announce) { e->e_to = q->q_paddr; *************** *** 161,167 **** for (q = e->e_errorqueue; q != NULL; q = q->q_next) { if (!bitset(QDONTSEND, q->q_flags)) ! fprintf(tfp, "E%s\n", q->q_paddr); } /* --- 156,162 ---- for (q = e->e_errorqueue; q != NULL; q = q->q_next) { if (!bitset(QDONTSEND, q->q_flags)) ! fprintf(tfp, "E%s\n", denlstring(q->q_paddr)); } /* *** /usr/src/usr.lib/sendmail/src/readcf.c.old Wed Feb 10 15:26:25 1988 --- /usr/src/usr.lib/sendmail/src/readcf.c Tue Mar 7 20:50:14 1995 *************** *** 9,15 **** */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)readcf.c 5.10 (Berkeley) 1/11/86"; #endif # include "sendmail.h" --- 9,15 ---- */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)readcf.c 5.10.1 (2.11BSD GTE) 3/07/95"; #endif # include "sendmail.h" *************** *** 648,654 **** setoption(opt, val, safe, sticky) char opt; ! char *val; bool safe; bool sticky; { --- 648,654 ---- setoption(opt, val, safe, sticky) char opt; ! register char *val; bool safe; bool sticky; { *************** *** 658,663 **** --- 658,664 ---- extern int RefuseLA; extern bool trusteduser(); extern char *username(); + register char *p; # ifdef DEBUG if (tTd(37, 1)) *************** *** 803,809 **** break; case 'M': /* define macro */ ! define(val[0], newstr(&val[1]), CurEnv); sticky = FALSE; break; --- 804,813 ---- break; case 'M': /* define macro */ ! p = newstr(&val[1]); ! if (!safe) ! cleanstrcpy(p, p, MAXNAME); ! define(val[0], p, CurEnv); sticky = FALSE; break; *************** *** 863,876 **** break; case 't': /* time zone name */ - # ifdef V6 - StdTimezone = newstr(val); - DstTimezone = index(StdTimeZone, ','); - if (DstTimezone == NULL) - syserr("bad time zone spec"); - else - *DstTimezone++ = '\0'; - # endif V6 break; case 'u': /* set default uid */ --- 867,872 ---- *** /usr/src/usr.lib/sendmail/src/recipient.c.old Wed Jul 13 21:12:14 1994 --- /usr/src/usr.lib/sendmail/src/recipient.c Tue Mar 7 20:58:31 1995 *************** *** 9,15 **** */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)recipient.c 5.7.1 (2.11BSD GTE) 7/13/94"; #endif # include --- 9,15 ---- */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)recipient.c 5.7.2 (2.11BSD GTE) 3/07/95"; #endif # include *************** *** 50,55 **** --- 50,58 ---- bool firstone; /* set on first address sent */ bool selfref; /* set if this list includes ctladdr */ char delimiter; /* the address delimiter */ + int i; + char *bufp; + char buf[MAXNAME + 1]; # ifdef DEBUG if (tTd(25, 1)) *************** *** 72,78 **** selfref = FALSE; al = NULL; ! for (p = list; *p != '\0'; ) { register ADDRESS *a; extern char *DelimChar; /* defined in prescan */ --- 75,89 ---- selfref = FALSE; al = NULL; ! /* make sure we have enough space to copy the string */ ! i = strlen(list) + 1; ! if (i < sizeof buf) ! bufp = buf; ! else ! bufp = xalloc(i); ! strcpy(bufp, denlstring(list)); ! ! for (p = bufp; *p != '\0'; ) { register ADDRESS *a; extern char *DelimChar; /* defined in prescan */ *************** *** 119,124 **** --- 130,137 ---- } CurEnv->e_to = NULL; + if (bufp != buf) + free(bufp); } /* ** RECIPIENT -- Designate a message recipient *** /usr/src/usr.lib/sendmail/src/savemail.c.old Wed Feb 10 15:26:27 1988 --- /usr/src/usr.lib/sendmail/src/savemail.c Tue Mar 7 21:02:09 1995 *************** *** 9,15 **** */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)savemail.c 5.7 (Berkeley) 12/7/85"; #endif # include --- 9,15 ---- */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)savemail.c 5.7.1 (2.11BSD GTE) 3/7/95"; #endif # include *************** *** 401,407 **** addheader("to", q->q_paddr, ee); } ! (void) sprintf(buf, "Returned mail: %s", msg); addheader("subject", buf, ee); /* fake up an address header for the from person */ --- 401,407 ---- addheader("to", q->q_paddr, ee); } ! (void) sprintf(buf, "Returned mail: %.*s", sizeof buf - 20, msg); addheader("subject", buf, ee); /* fake up an address header for the from person */ *** /usr/src/usr.lib/sendmail/src/sendmail.h.old Fri Jul 15 14:40:40 1994 --- /usr/src/usr.lib/sendmail/src/sendmail.h Mon Mar 6 21:42:03 1995 *************** *** 7,13 **** ** All rights reserved. The Berkeley software License Agreement ** specifies the terms and conditions for redistribution. ** ! ** @(#)sendmail.h 5.8.1 (2.11BSD GTE) 7/15/94 */ /* --- 7,13 ---- ** All rights reserved. The Berkeley software License Agreement ** specifies the terms and conditions for redistribution. ** ! ** @(#)sendmail.h 5.8.2 (2.11BSD GTE) 3/6/95 */ /* *************** *** 19,25 **** # ifdef _DEFINE # define EXTERN # if !defined(lint) && !defined(NOSCCS) ! static char SmailSccsId[] = "@(#)sendmail.h 5.8.1 7/15/94"; # endif lint # else _DEFINE # define EXTERN extern --- 19,25 ---- # ifdef _DEFINE # define EXTERN # if !defined(lint) && !defined(NOSCCS) ! static char SmailSccsId[] = "@(#)sendmail.h 5.8.2 3/6/95"; # endif lint # else _DEFINE # define EXTERN extern *************** *** 577,579 **** --- 577,581 ---- extern char *sfgets(); extern char *queuename(); extern time_t curtime(); + extern bool shouldqueue(); + extern char *denlstring(); *** /usr/src/usr.lib/sendmail/src/util.c.old Mon Oct 10 21:41:56 1988 --- /usr/src/usr.lib/sendmail/src/util.c Tue Mar 7 21:29:24 1995 *************** *** 9,15 **** */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)util.c 5.8 (Berkeley) 12/17/85"; #endif # include --- 9,15 ---- */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)util.c 5.8.1 (2.11BSD GTE) 3/07/95"; #endif # include *************** *** 19,24 **** --- 19,25 ---- # include # include # include "sendmail.h" + #include /* ** STRIPQUOTES -- Strip quotes & quote bits from a string. *************** *** 679,686 **** char * fgetfolded(buf, n, f) char *buf; ! register int n; ! FILE *f; { register char *p = buf; register int i; --- 680,687 ---- char * fgetfolded(buf, n, f) char *buf; ! int n; ! register FILE *f; { register char *p = buf; register int i; *************** *** 801,807 **** int pid; { auto int st; ! int i; do { --- 802,808 ---- int pid; { auto int st; ! register int i; do { *************** *** 831,837 **** BITMAP a; BITMAP b; { ! int i; for (i = BITMAPBYTES / sizeof (int); --i >= 0; ) if ((a[i] & b[i]) != 0) --- 832,838 ---- BITMAP a; BITMAP b; { ! register int i; for (i = BITMAPBYTES / sizeof (int); --i >= 0; ) if ((a[i] & b[i]) != 0) *************** *** 856,865 **** bitzerop(map) BITMAP map; { ! int i; for (i = BITMAPBYTES / sizeof (int); --i >= 0; ) if (map[i] != 0) return (FALSE); return (TRUE); } --- 857,952 ---- bitzerop(map) BITMAP map; { ! register int i; for (i = BITMAPBYTES / sizeof (int); --i >= 0; ) if (map[i] != 0) return (FALSE); return (TRUE); + } + /* + ** CLEANSTRCPY -- copy string keeping out bogus characters + ** + ** Parameters: + ** t -- "to" string. + ** f -- "from" string. + ** l -- length of space available in "to" string. + ** + ** Returns: + ** none. + */ + + void + cleanstrcpy(t, f, l) + register char *t; + register char *f; + int l; + { + #ifdef LOG + /* check for newlines and log if necessary */ + (void) denlstring(f); + #endif + + l--; + while (l > 0 && *f != '\0') + { + if (isascii(*f) && + (isalnum(*f) || strchr("!#$%&'*+-./^_`{|}~", *f) != NULL)) + { + l--; + *t++ = *f; + } + f++; + } + *t = '\0'; + } + /* + ** DENLSTRING -- convert newlines in a string to spaces + ** + ** Parameters: + ** s -- the input string + ** + ** Returns: + ** A pointer to a version of the string with newlines + ** mapped to spaces. This should be copied. + */ + + char * + denlstring(s) + char *s; + { + register char *p; + int l; + static char *bp = NULL; + static int bl = 0; + extern char *macvalue(); + + if (strchr(s, '\n') == NULL) + return s; + + l = strlen(s) + 1; + if (bl < l) + { + /* allocate more space */ + if (bp != NULL) + free(bp); + bp = xalloc(l); + bl = l; + } + strcpy(bp, s); + for (p = bp; (p = strchr(p, '\n')) != NULL; ) + *p++ = ' '; + + #ifdef LOG + /* + * V5 doesn't have IDENT capabilities so there is no macro '_'. + * Instead we use the less "trusted" (but better than nothing) 'f' + * macro value. + */ + p = macvalue('f', CurEnv); + syslog(LOG_ALERT, "POSSIBLE ATTACK from %s: newline in string \"%s\"", + p == NULL ? "[UNKNOWN]" : p, bp); + #endif + + return bp; } *** /VERSION.old Thu Mar 9 19:26:13 1995 --- /VERSION Thu Mar 9 20:30:05 1995 *************** *** 1,4 **** ! Current Patch Level: 229 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 230 2.11 BSD ============