From 6d1607664dbe8ff610f1c84563f905abacbe8953 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 23 Aug 2005 15:28:06 +0000 Subject: [PATCH] sendmail tried to limit directory names to MAXPATHLEN - MAXNAMLEN in an attempt to bound the size of full path names. This is bogus, because most directory entries are much shorter than MAXNAMLEN and some filesystems might allow longer path names than MAXNAMLEN. Change the logic to bound all path names to PATH_MAX by checking the return values of sm_strlcpy. --- usr.sbin/sendmail/Makefile | 7 ++++-- usr.sbin/sendmail/mci.c.patch | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 usr.sbin/sendmail/mci.c.patch diff --git a/usr.sbin/sendmail/Makefile b/usr.sbin/sendmail/Makefile index 0710a4a6f9..cf8172cb22 100644 --- a/usr.sbin/sendmail/Makefile +++ b/usr.sbin/sendmail/Makefile @@ -1,11 +1,14 @@ # @(#)Makefile 8.8 (Berkeley) 3/28/97 # $FreeBSD: src/usr.sbin/sendmail/Makefile,v 1.15.2.13 2002/03/25 21:32:29 gshapiro Exp $ -# $DragonFly: src/usr.sbin/sendmail/Makefile,v 1.11 2005/08/17 02:47:06 gshapiro Exp $ +# $DragonFly: src/usr.sbin/sendmail/Makefile,v 1.12 2005/08/23 15:28:06 joerg Exp $ SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail-8.13.4 SMDIR= ${SENDMAIL_DIR}/sendmail .PATH: ${SMDIR} +CONTRIBDIR= ${SMDIR} +PATCHES= mci.c.patch + BINDIR= /usr/libexec/sendmail PROG= sendmail @@ -17,7 +20,7 @@ SRCS= alias.c arpadate.c bf.c collect.c conf.c control.c \ macro.c main.c map.c mci.c milter.c mime.c parseaddr.c queue.c \ ratectrl.c readcf.c recipient.c savemail.c sasl.c sfsasl.c \ shmticklib.c sm_resolve.c srvrsmtp.c stab.c stats.c sysexits.c \ - timers.c tls.c trace.c udb.c usersmtp.c util.c version.c + timers.c tls.c trace.c udb.c usersmtp.c util.c version.c ${PATCHES} BINOWN= root BINGRP= smmsp .ifdef SENDMAIL_SET_USER_ID diff --git a/usr.sbin/sendmail/mci.c.patch b/usr.sbin/sendmail/mci.c.patch new file mode 100644 index 0000000000..2cb62bc001 --- /dev/null +++ b/usr.sbin/sendmail/mci.c.patch @@ -0,0 +1,47 @@ +$DragonFly: src/usr.sbin/sendmail/mci.c.patch,v 1.1 2005/08/23 15:28:06 joerg Exp $ + +Index: mci.c +=================================================================== +RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/sendmail-8.13.4/sendmail/mci.c,v +retrieving revision 1.1.1.1 +diff -u -r1.1.1.1 mci.c +--- mci.c 6 Jun 2005 04:25:22 -0000 1.1.1.1 ++++ mci.c 23 Aug 2005 15:04:54 -0000 +@@ -1125,7 +1125,7 @@ + size_t len; + char *newptr; + struct dirent *e; +- char newpath[MAXPATHLEN]; ++ char newpath[PATH_MAX]; + + if ((d = opendir(pathname)) == NULL) + { +@@ -1134,7 +1134,7 @@ + pathname, sm_errstring(errno)); + return -1; + } +- len = sizeof(newpath) - MAXNAMLEN - 3; ++ len = sizeof(newpath) - 2; /* enough space for '/' and NUL */ + if (sm_strlcpy(newpath, pathname, len) >= len) + { + if (tTd(56, 2)) +@@ -1144,6 +1144,7 @@ + } + newptr = newpath + strlen(newpath); + *newptr++ = '/'; ++ len = sizeof(newpath) - (newptr - newpath); + + /* + ** repeat until no file has been removed +@@ -1160,9 +1161,8 @@ + if (e->d_name[0] == '.') + continue; + +- (void) sm_strlcpy(newptr, e->d_name, +- sizeof newpath - +- (newptr - newpath)); ++ if (sm_strlcpy(newptr, e->d_name, len) >= len) ++ continue; + + if (StopRequest) + stop_sendmail(); -- 2.41.0